that and callers wind up typecasting it back.
#include "busybox.h"
#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef CONFIG_FEATURE_SUID_CONFIG
-#include <sys/stat.h>
#include <ctype.h>
#include "pwd_.h"
#include "grp_.h"
/* Next, advance past all leading space and return a ptr to the
* first non-space char; possibly the terminating nul. */
- return (char *) bb_skip_whitespace(s);
+ return skip_whitespace(s);
}
/* Get the specified mode. */
- e = (char *) bb_skip_whitespace(e+1);
+ e = skip_whitespace(e+1);
for (i=0 ; i < 3 ; i++) {
const char *q;
/* Now get the the user/group info. */
- s = (char *) bb_skip_whitespace(e);
+ s = skip_whitespace(e);
/* Note: We require whitespace between the mode and the
* user/group info. */
/************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
+#include "busybox.h"
#include <unistd.h>
-#include <dirent.h>
#include <errno.h>
-#include <stdio.h>
#include <string.h>
-#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
-#include <termios.h>
#include <getopt.h> /* struct option */
#include <sys/ioctl.h>
#include <sys/sysmacros.h> /* major() and minor() */
-#include "busybox.h"
-#ifdef CONFIG_SELINUX
-#include <selinux/selinux.h> /* for is_selinux_enabled() */
-#endif
-
-#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
#include <time.h>
-#endif
/* what is the overall style of the listing */
-#define STYLE_AUTO (0)
#define STYLE_COLUMNS (1U<<21) /* fill columns */
#define STYLE_LONG (2U<<21) /* one record per line, extended info */
#define STYLE_SINGLE (3U<<21) /* one record per line */
#define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_DIRNAME - 1))
-#ifdef CONFIG_FEATURE_LS_SORTFILES
+// CONFIG_FEATURE_LS_SORTFILES
/* how will the files be sorted */
#define SORT_ORDER_FORWARD 0 /* sort in reverse order */
#define SORT_ORDER_REVERSE (1U<<27) /* sort in reverse order */
#define SORT_DIR (7U<<28) /* sort by file or directory */
#define SORT_MASK (7U<<28)
-#endif
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
if (dif == 0) {
/* sort by name- may be a tie_breaker for time or size cmp */
-#ifdef CONFIG_LOCALE_SUPPORT
- dif = strcoll(d1->name, d2->name);
-#else
- dif = strcmp(d1->name, d2->name);
-#endif
+ if (ENABLE_LOCALE_SUPPORT) dif = strcoll(d1->name, d2->name);
+ else dif = strcmp(d1->name, d2->name);
}
if (all_fmt & SORT_ORDER_REVERSE) {
{
qsort(dn, size, sizeof *dn, sortcmp);
}
+#else
+#define sortcmp(a, b) 0
+#define dnsort(dn, size)
#endif
+
/*----------------------------------------------------------------------*/
static void showfiles(struct dnode **dn, int nfiles)
{
{
int i, nfiles;
struct dnode **subdnp;
-
-#ifdef CONFIG_FEATURE_LS_RECURSIVE
int dndirs;
struct dnode **dnd;
-#endif
if (dn == NULL || ndirs < 1)
return;
nfiles = countfiles(subdnp);
if (nfiles > 0) {
/* list all files at this level */
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- dnsort(subdnp, nfiles);
-#endif
+ if (ENABLE_FEATURE_LS_SORTFILES) dnsort(subdnp, nfiles);
showfiles(subdnp, nfiles);
#ifdef CONFIG_FEATURE_LS_RECURSIVE
if (all_fmt & DISP_RECURSIVE) {
dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
dndirs = countsubdirs(subdnp, nfiles);
if (dndirs > 0) {
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- dnsort(dnd, dndirs);
-#endif
+ if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnd, dndirs);
showdirs(dnd, dndirs, 0);
free(dnd); /* free the array of dnode pointers to the dirs */
}
# define LS_STR_TIMESTAMPS ""
#endif
-#ifdef CONFIG_FEATURE_LS_SORTFILES
-# define LS_STR_SORTFILES "SXrv"
-#else
-# define LS_STR_SORTFILES ""
-#endif
-
#ifdef CONFIG_FEATURE_LS_FILETYPES
# define LS_STR_FILETYPES "Fp"
#else
static const char ls_options[]="Cadil1gnsxAk" \
LS_STR_TIMESTAMPS \
- LS_STR_SORTFILES \
+ USE_FEATURE_LS_SORTFILES("SXrv") \
LS_STR_FILETYPES \
LS_STR_FOLLOW_LINKS \
LS_STR_RECURSIVE \
0, /* k - ingored */
#endif
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
-# ifdef CONFIG_FEATURE_LS_SORTFILES
- TIME_CHANGE | SORT_CTIME, /* c */
-# else
- TIME_CHANGE, /* c */
-# endif
+ TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
LIST_FULLTIME, /* e */
-# ifdef CONFIG_FEATURE_LS_SORTFILES
- SORT_MTIME, /* t */
-# else
- 0, /* t - ignored -- is this correct? */
-# endif
-# ifdef CONFIG_FEATURE_LS_SORTFILES
- TIME_ACCESS | SORT_ATIME, /* u */
-# else
- TIME_ACCESS, /* u */
-# endif
+ ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
+ TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
#endif
#ifdef CONFIG_FEATURE_LS_SORTFILES
SORT_SIZE, /* S */
char *color_opt;
#endif
- all_fmt = LIST_SHORT | STYLE_AUTO
-#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
- | TIME_MOD
-#endif
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- | SORT_NAME | SORT_ORDER_FORWARD
-#endif
- ;
+ all_fmt = LIST_SHORT | (ENABLE_FEATURE_LS_TIMESTAMPS * TIME_MOD) |
+ (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_ORDER_FORWARD));
#ifdef CONFIG_FEATURE_AUTOWIDTH
/* Obtain the terminal width. */
if (flags & STYLE_MASK_TRIGGER) {
all_fmt &= ~STYLE_MASK;
}
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- if (flags & SORT_MASK_TRIGGER) {
+ if (ENABLE_FEATURE_LS_SORTFILES && (flags & SORT_MASK_TRIGGER)) {
all_fmt &= ~SORT_MASK;
}
-#endif
if (flags & DISP_MASK_TRIGGER) {
all_fmt &= ~DISP_MASK;
}
if (all_fmt & DISP_NOLIST)
all_fmt &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
#endif
-#if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES)
- if (all_fmt & TIME_CHANGE)
- all_fmt = (all_fmt & ~SORT_MASK) | SORT_CTIME;
- if (all_fmt & TIME_ACCESS)
- all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME;
-#endif
+ if (ENABLE_FEATURE_LS_TIMESTAMPS && ENABLE_FEATURE_LS_SORTFILES) {
+ if (all_fmt & TIME_CHANGE)
+ all_fmt = (all_fmt & ~SORT_MASK) | SORT_CTIME;
+ if (all_fmt & TIME_ACCESS)
+ all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME;
+ }
if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */
all_fmt &= ~(LIST_ID_NUMERIC|LIST_FULLTIME|LIST_ID_NAME|LIST_ID_NUMERIC);
#ifdef CONFIG_FEATURE_LS_USERNAME
#endif
/* choose a display format */
- if ((all_fmt & STYLE_MASK) == STYLE_AUTO)
-#if STYLE_AUTO != 0
- all_fmt = (all_fmt & ~STYLE_MASK)
- | (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
-#else
+ if (!(all_fmt & STYLE_MASK))
all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
-#endif
/*
* when there are no cmd line args we have to supply a default "." arg.
}
if (all_fmt & DISP_NOLIST) {
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- dnsort(dnp, nfiles);
-#endif
+ if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnp, nfiles);
if (nfiles > 0)
showfiles(dnp, nfiles);
} else {
dndirs = countdirs(dnp, nfiles);
dnfiles = nfiles - dndirs;
if (dnfiles > 0) {
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- dnsort(dnf, dnfiles);
-#endif
+ if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnf, dnfiles);
showfiles(dnf, dnfiles);
if (ENABLE_FEATURE_CLEAN_UP)
free(dnf);
}
if (dndirs > 0) {
-#ifdef CONFIG_FEATURE_LS_SORTFILES
- dnsort(dnd, dndirs);
-#endif
+ if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnd, dndirs);
showdirs(dnd, dndirs, dnfiles == 0);
if (ENABLE_FEATURE_CLEAN_UP)
free(dnd);
* "This program is in the Public Domain."
*/
-#include <sys/types.h>
+#include "busybox.h"
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
-#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
-#include "busybox.h"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
if (errno != 0)
syntax(s, "out of range");
- /* p = bb_skip_whitespace(p); avoid const warning */
- if (*(bb_skip_whitespace(p)))
+ if (*(skip_whitespace(p)))
syntax(s, "bad number");
return r;
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */
-#include <stdio.h>
-#include <stdlib.h>
+#include "busybox.h"
#include <string.h>
#include <ctype.h>
#include <unistd.h>
-#include "busybox.h"
static const char uniq_opts[] = "f:s:" "cdu\0\1\2\4";
while ((s1 = bb_get_chomped_line_from_file(in)) != NULL) {
e1 = s1;
for (i=skip_fields ; i ; i--) {
- e1 = bb_skip_whitespace(e1);
+ e1 = skip_whitespace(e1);
while (*e1 && !isspace(*e1)) {
++e1;
}
extern void chomp(char *s);
extern void trim(char *s);
-extern const char *bb_skip_whitespace(const char *);
+extern char *skip_whitespace(const char *);
extern struct BB_applet *find_applet_by_name(const char *name);
void run_applet_by_name(const char *name, int argc, char **argv);
* Original copyright notice is retained at the end of this file.
*/
-#include <stdlib.h>
+#include "libbb.h"
#include <string.h>
#include <unistd.h>
#include <ctype.h> /* for isdigit() */
-#include "libbb.h"
#include "dump.h"
enum _vflag bb_dump_vflag = FIRST;
static void rewrite(FS * fs)
{
enum { NOTOKAY, USEBCNT, USEPREC } sokay;
- register PR *pr, **nextpr = NULL;
- register FU *fu;
- register char *p1, *p2, *p3;
+ PR *pr, **nextpr = NULL;
+ FU *fu;
+ char *p1, *p2, *p3;
char savech, *fmtp;
const char *byte_count_str;
int nconv, prec = 0;
for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
/* NOSTRICT */
/* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/
- pr = (PR *) xzalloc(sizeof(PR));
+ pr = xzalloc(sizeof(PR));
if (!fu->nextpr)
fu->nextpr = pr;
/* ignore nextpr -- its unused inside the loop and is
{
savech = *p3;
*p3 = '\0';
- if (!(pr->fmt = realloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1)))
- bb_perror_msg_and_die("hexdump");
+ pr->fmt = xrealloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1);
strcat(pr->fmt, p2);
*p3 = savech;
p2 = p3;
void bb_dump_add(const char *fmt)
{
- register const char *p;
- register char *p1;
- register char *p2;
+ const char *p;
+ char *p1;
+ char *p2;
static FS **nextfs;
FS *tfs;
FU *tfu, **nextfu;
const char *savep;
/* start new linked list of format units */
- /* NOSTRICT */
- tfs = (FS *) xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
+ tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
if (!bb_dump_fshead) {
bb_dump_fshead = tfs;
} else {
/* take the format string and break it up into format units */
for (p = fmt;;) {
/* bb_dump_skip leading white space */
- p = bb_skip_whitespace(p);
+ p = skip_whitespace(p);
if (!*p) {
break;
}
/* allocate a new format unit and link it in */
/* NOSTRICT */
/* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */
- tfu = (FU *) xzalloc(sizeof(FU));
+ tfu = xzalloc(sizeof(FU));
*nextfu = tfu;
nextfu = &tfu->nextfu;
tfu->reps = 1;
tfu->reps = atoi(savep);
tfu->flags = F_SETREP;
/* bb_dump_skip trailing white space */
- p = bb_skip_whitespace(++p);
+ p = skip_whitespace(++p);
}
/* bb_dump_skip slash and trailing white space */
if (*p == '/') {
- p = bb_skip_whitespace(++p);
+ p = skip_whitespace(++p);
}
/* byte count */
}
tfu->bcnt = atoi(savep);
/* bb_dump_skip trailing white space */
- p = bb_skip_whitespace(++p);
+ p = skip_whitespace(++p);
}
/* format */
*
*/
+#include "libbb.h"
#include "inet_common.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "libbb.h"
#ifdef DEBUG
# include <resolv.h>
*
*/
+#include "libbb.h"
#include <string.h>
#include <crypt.h>
-#include "libbb.h"
char *pw_encrypt(const char *clear, const char *salt)
*
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <ctype.h>
#include "libbb.h"
-const char *bb_skip_whitespace(const char *s)
+char *skip_whitespace(const char *s)
{
- while (isspace(*s)) {
- ++s;
- }
+ while (isspace(*s)) ++s;
- return s;
+ return (char *) s;
}
*
*/
+#include "libbb.h"
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
-#include "pwd_.h"
-#include "grp_.h"
-#include "shadow_.h"
-#include "libbb.h"
+//#include "pwd_.h"
+//#include "grp_.h"
+//#include "shadow_.h"
#ifndef _PATH_SHADOW
#define _PATH_SHADOW "/etc/shadow"
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
*/
-#include <stdio.h>
-#include <arpa/inet.h>
+#include "libbb.h"
#include <string.h>
#include "rt_names.h"
* Copyright (c) 1989
* The Regents of the University of California. All rights reserved.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Original copyright notice is retained at the end of this file.
+ * Licensed under GPLv2 or later, see file License in this tarball for details.
*/
+#include "busybox.h"
#include <getopt.h>
-#include <stdlib.h>
#include <string.h>
-#include "busybox.h"
#include "dump.h"
static void bb_dump_addfile(char *name)
fp = bb_xfopen(name, "r");
while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) {
- p = (char *) bb_skip_whitespace(buf);
+ p = skip_whitespace(buf);
if (*p && (*p != '#')) {
bb_dump_add(p);
return(bb_dump_dump(argv));
}
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */