mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-06 02:27:15 +00:00
cleanified old style C function declaration from utils.c
This commit is contained in:
parent
4404ef0281
commit
3120487243
@ -586,23 +586,19 @@ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Procedures exported from utils.c. */
|
/* Procedures exported from utils.c. */
|
||||||
void print_string (char *, int, void (*) (void *, char *, ...),
|
void print_string(char *p, int len, void (*printer) (void *, char *, ...), void *arg); /* Format a string for output */
|
||||||
void *); /* Format a string for output */
|
int slprintf(char *buf, int buflen, char *fmt, ...); /* sprintf++ */
|
||||||
int slprintf (char *, int, char *, ...); /* sprintf++ */
|
int vslprintf(char *buf, int buflen, char *fmt, va_list args); /* vsprintf++ */
|
||||||
int vslprintf (char *, int, char *, va_list); /* vsprintf++ */
|
size_t strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */
|
||||||
size_t strlcpy (char *, const char *, size_t); /* safe strcpy */
|
size_t strlcat(char *dest, const char *src, size_t len); /* safe strncpy */
|
||||||
size_t strlcat (char *, const char *, size_t); /* safe strncpy */
|
void dbglog(char *fmt, ...); /* log a debug message */
|
||||||
void dbglog (char *, ...); /* log a debug message */
|
void info(char *fmt, ...); /* log an informational message */
|
||||||
void info (char *, ...); /* log an informational message */
|
void notice(char *fmt, ...); /* log a notice-level message */
|
||||||
void notice (char *, ...); /* log a notice-level message */
|
void warn(char *fmt, ...); /* log a warning message */
|
||||||
void warn (char *, ...); /* log a warning message */
|
void error(char *fmt, ...); /* log an error message */
|
||||||
void error (char *, ...); /* log an error message */
|
void fatal(char *fmt, ...); /* log an error message and die(1) */
|
||||||
void fatal (char *, ...); /* log an error message and die(1) */
|
|
||||||
void init_pr_log (const char *, int); /* initialize for using pr_log */
|
|
||||||
void pr_log (void *, char *, ...); /* printer fn, output to syslog */
|
|
||||||
void end_pr_log (void); /* finish up after using pr_log */
|
|
||||||
#if PRINTPKT_SUPPORT
|
#if PRINTPKT_SUPPORT
|
||||||
void dump_packet (const char *, u_char *, int);
|
void dump_packet(const char *tag, unsigned char *p, int len);
|
||||||
/* dump packet to debug log if interesting */
|
/* dump packet to debug log if interesting */
|
||||||
#endif /* PRINTPKT_SUPPORT */
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
|
@ -69,12 +69,12 @@
|
|||||||
extern char *strerror();
|
extern char *strerror();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void logit (int, char *, va_list);
|
static void logit(int level, char *fmt, va_list args);
|
||||||
static void log_write (int, char *);
|
static void log_write(int level, char *buf);
|
||||||
#if PRINTPKT_SUPPORT
|
#if PRINTPKT_SUPPORT
|
||||||
static void vslp_printer (void *, char *, ...);
|
static void vslp_printer(void *arg, char *fmt, ...);
|
||||||
static void format_packet (u_char *, int, void (*) (void *, char *, ...),
|
static void format_packet(u_char *p, int len,
|
||||||
void *);
|
void (*printer) (void *, char *, ...), void *arg);
|
||||||
|
|
||||||
struct buffer_info {
|
struct buffer_info {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -86,12 +86,7 @@ struct buffer_info {
|
|||||||
* strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
|
* strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
|
||||||
* always leaves destination null-terminated (for len > 0).
|
* always leaves destination null-terminated (for len > 0).
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t strlcpy(char *dest, const char *src, size_t len) {
|
||||||
strlcpy(dest, src, len)
|
|
||||||
char *dest;
|
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
{
|
|
||||||
size_t ret = strlen(src);
|
size_t ret = strlen(src);
|
||||||
|
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
@ -109,12 +104,7 @@ strlcpy(dest, src, len)
|
|||||||
* strlcat - like strcat/strncat, doesn't overflow destination buffer,
|
* strlcat - like strcat/strncat, doesn't overflow destination buffer,
|
||||||
* always leaves destination null-terminated (for len > 0).
|
* always leaves destination null-terminated (for len > 0).
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t strlcat(char *dest, const char *src, size_t len) {
|
||||||
strlcat(dest, src, len)
|
|
||||||
char *dest;
|
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
{
|
|
||||||
size_t dlen = strlen(dest);
|
size_t dlen = strlen(dest);
|
||||||
|
|
||||||
return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
|
return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
|
||||||
@ -129,9 +119,7 @@ strlcat(dest, src, len)
|
|||||||
* Doesn't do floating-point formats.
|
* Doesn't do floating-point formats.
|
||||||
* Returns the number of chars put into buf.
|
* Returns the number of chars put into buf.
|
||||||
*/
|
*/
|
||||||
int
|
int slprintf(char *buf, int buflen, char *fmt, ...) {
|
||||||
slprintf (char *buf, int buflen, char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
va_list args;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -146,13 +134,7 @@ slprintf (char *buf, int buflen, char *fmt, ...)
|
|||||||
*/
|
*/
|
||||||
#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
|
#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
|
||||||
|
|
||||||
int
|
int vslprintf(char *buf, int buflen, char *fmt, va_list args) {
|
||||||
vslprintf(buf, buflen, fmt, args)
|
|
||||||
char *buf;
|
|
||||||
int buflen;
|
|
||||||
char *fmt;
|
|
||||||
va_list args;
|
|
||||||
{
|
|
||||||
int c, i, n;
|
int c, i, n;
|
||||||
int width, prec, fillch;
|
int width, prec, fillch;
|
||||||
int base, len, neg, quoted;
|
int base, len, neg, quoted;
|
||||||
@ -431,9 +413,7 @@ vslprintf(buf, buflen, fmt, args)
|
|||||||
/*
|
/*
|
||||||
* vslp_printer - used in processing a %P format
|
* vslp_printer - used in processing a %P format
|
||||||
*/
|
*/
|
||||||
static void
|
static void vslp_printer(void *arg, char *fmt, ...) {
|
||||||
vslp_printer (void *arg, char *fmt, ...)
|
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
struct buffer_info *bi;
|
struct buffer_info *bi;
|
||||||
@ -471,13 +451,8 @@ log_packet(p, len, prefix, level)
|
|||||||
* format_packet - make a readable representation of a packet,
|
* format_packet - make a readable representation of a packet,
|
||||||
* calling `printer(arg, format, ...)' to output it.
|
* calling `printer(arg, format, ...)' to output it.
|
||||||
*/
|
*/
|
||||||
static void
|
static void format_packet(u_char *p, int len,
|
||||||
format_packet(p, len, printer, arg)
|
void (*printer) (void *, char *, ...), void *arg) {
|
||||||
u_char *p;
|
|
||||||
int len;
|
|
||||||
void (*printer) (void *, char *, ...);
|
|
||||||
void *arg;
|
|
||||||
{
|
|
||||||
int i, n;
|
int i, n;
|
||||||
u_short proto;
|
u_short proto;
|
||||||
struct protent *protp;
|
struct protent *protp;
|
||||||
@ -635,23 +610,14 @@ void print_string(char *p, int len, void (*printer) (void *, char *, ...), void
|
|||||||
/*
|
/*
|
||||||
* logit - does the hard work for fatal et al.
|
* logit - does the hard work for fatal et al.
|
||||||
*/
|
*/
|
||||||
static void
|
static void logit(int level, char *fmt, va_list args) {
|
||||||
logit(level, fmt, args)
|
|
||||||
int level;
|
|
||||||
char *fmt;
|
|
||||||
va_list args;
|
|
||||||
{
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
vslprintf(buf, sizeof(buf), fmt, args);
|
vslprintf(buf, sizeof(buf), fmt, args);
|
||||||
log_write(level, buf);
|
log_write(level, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void log_write(int level, char *buf) {
|
||||||
log_write(level, buf)
|
|
||||||
int level;
|
|
||||||
char *buf;
|
|
||||||
{
|
|
||||||
PPPDEBUG(level, ("%s\n", buf) );
|
PPPDEBUG(level, ("%s\n", buf) );
|
||||||
#if 0
|
#if 0
|
||||||
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
|
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
|
||||||
@ -669,9 +635,7 @@ log_write(level, buf)
|
|||||||
/*
|
/*
|
||||||
* fatal - log an error message and die horribly.
|
* fatal - log an error message and die horribly.
|
||||||
*/
|
*/
|
||||||
void
|
void fatal(char *fmt, ...) {
|
||||||
fatal (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -687,9 +651,7 @@ fatal (char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* error - log an error message.
|
* error - log an error message.
|
||||||
*/
|
*/
|
||||||
void
|
void error(char *fmt, ...) {
|
||||||
error (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -703,9 +665,7 @@ error (char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* warn - log a warning message.
|
* warn - log a warning message.
|
||||||
*/
|
*/
|
||||||
void
|
void warn(char *fmt, ...) {
|
||||||
warn (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -716,9 +676,7 @@ warn (char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* notice - log a notice-level message.
|
* notice - log a notice-level message.
|
||||||
*/
|
*/
|
||||||
void
|
void notice(char *fmt, ...) {
|
||||||
notice (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -729,9 +687,7 @@ notice (char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* info - log an informational message.
|
* info - log an informational message.
|
||||||
*/
|
*/
|
||||||
void
|
void info(char *fmt, ...) {
|
||||||
info (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -742,9 +698,7 @@ info (char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* dbglog - log a debug message.
|
* dbglog - log a debug message.
|
||||||
*/
|
*/
|
||||||
void
|
void dbglog(char *fmt, ...) {
|
||||||
dbglog (char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list pvar;
|
va_list pvar;
|
||||||
|
|
||||||
va_start(pvar, fmt);
|
va_start(pvar, fmt);
|
||||||
@ -757,9 +711,7 @@ dbglog (char *fmt, ...)
|
|||||||
* dump_packet - print out a packet in readable form if it is interesting.
|
* dump_packet - print out a packet in readable form if it is interesting.
|
||||||
* Assumes len >= PPP_HDRLEN.
|
* Assumes len >= PPP_HDRLEN.
|
||||||
*/
|
*/
|
||||||
void
|
void dump_packet(const char *tag, unsigned char *p, int len) {
|
||||||
dump_packet(const char *tag, unsigned char *p, int len)
|
|
||||||
{
|
|
||||||
int proto;
|
int proto;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user