mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-11-25 04:39:48 +00:00
Split error messages into separate files.
Update libbb.h, per suggestion from Vladimir, to include __attribute__((format (printf ...))) stuff -Erik
This commit is contained in:
parent
cc165b9083
commit
b183dfad2d
5
Makefile
5
Makefile
@ -110,6 +110,8 @@ OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>
|
||||
|
||||
WARNINGS = -Wall
|
||||
|
||||
ARFLAGS = -r
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
@ -233,7 +235,8 @@ mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c
|
||||
my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \
|
||||
recursive_action.c safe_read.c safe_strncpy.c syscalls.c \
|
||||
syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \
|
||||
xregcomp.c
|
||||
xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \
|
||||
verror_msg.c vperror_msg.c
|
||||
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
|
||||
LIBBB_CFLAGS = -I$(LIBBB_DIR)
|
||||
|
||||
|
@ -68,11 +68,15 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
|
||||
extern void show_usage(void) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...);
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
/* These two are used internally -- you shouldn't need to use them */
|
||||
extern void verror_msg(const char *s, va_list p);
|
||||
extern void vperror_msg(const char *s, va_list p);
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
|
11
libbb/Makefile
Normal file
11
libbb/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# Silly wrapper makefile. This Makefile is _not_ used by the build system for
|
||||
# busybox, it is just to make working on libbb more conveinient.
|
||||
# -Erik Andersen
|
||||
|
||||
all:
|
||||
make -C .. libbb.a
|
||||
|
||||
clean:
|
||||
- rm -rf libbb.a
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
|
@ -31,15 +31,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern const char *applet_name;
|
||||
|
||||
static void verror_msg(const char *s, va_list p)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: ", applet_name);
|
||||
vfprintf(stderr, s, p);
|
||||
}
|
||||
|
||||
extern void error_msg(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
@ -50,45 +41,6 @@ extern void error_msg(const char *s, ...)
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
extern void error_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
verror_msg(s, p);
|
||||
va_end(p);
|
||||
putc('\n', stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void vperror_msg(const char *s, va_list p)
|
||||
{
|
||||
int err=errno;
|
||||
if(s == 0) s = "";
|
||||
verror_msg(s, p);
|
||||
if (*s) s = ": ";
|
||||
fprintf(stderr, "%s%s\n", s, strerror(err));
|
||||
}
|
||||
|
||||
extern void perror_msg(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
}
|
||||
|
||||
extern void perror_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
|
53
libbb/error_msg_and_die.c
Normal file
53
libbb/error_msg_and_die.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void error_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
verror_msg(s, p);
|
||||
va_end(p);
|
||||
putc('\n', stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
@ -68,11 +68,15 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
|
||||
extern void show_usage(void) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...);
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
/* These two are used internally -- you shouldn't need to use them */
|
||||
extern void verror_msg(const char *s, va_list p);
|
||||
extern void vperror_msg(const char *s, va_list p);
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
|
51
libbb/perror_msg.c
Normal file
51
libbb/perror_msg.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void perror_msg(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
52
libbb/perror_msg_and_die.c
Normal file
52
libbb/perror_msg_and_die.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void perror_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
51
libbb/verror_msg.c
Normal file
51
libbb/verror_msg.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern const char *applet_name;
|
||||
|
||||
extern void verror_msg(const char *s, va_list p)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: ", applet_name);
|
||||
vfprintf(stderr, s, p);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
51
libbb/vperror_msg.c
Normal file
51
libbb/vperror_msg.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void vperror_msg(const char *s, va_list p)
|
||||
{
|
||||
int err=errno;
|
||||
if(s == 0) s = "";
|
||||
verror_msg(s, p);
|
||||
if (*s) s = ": ";
|
||||
fprintf(stderr, "%s%s\n", s, strerror(err));
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
Loading…
Reference in New Issue
Block a user