* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include "busybox.h"
-
-#if !defined CONFIG_SYSLOGD
-
+#include "libbb.h"
+#ifndef CONFIG_SYSLOGD
#define SYSLOG_NAMES
-#include <sys/syslog.h>
-
+#define SYSLOG_NAMES_CONST
+#include <syslog.h>
#else
-#include <sys/syslog.h>
-# ifndef __dietlibc__
- /* We have to do this since the header file defines static
- * structures. Argh.... bad libc, bad, bad...
- */
- typedef struct _code {
- char *c_name;
- int c_val;
- } CODE;
- extern CODE prioritynames[];
- extern CODE facilitynames[];
+/* brokenness alert. Everybody except dietlibc get's this wrong by neither
+ * providing a typedef nor an extern for facilitynames and prioritynames
+ * in syslog.h.
+ */
+# include <syslog.h>
+# ifndef __dietlibc__
+/* We have to do this since the header file does neither provide a sane type
+ * for this structure nor extern definitions. Argh.... bad libc, bad, bad...
+ */
+typedef struct _code {
+ char *c_name; /* FIXME: this should be const char *const c_name ! */
+ int c_val;
+} CODE;
+# ifdef __UCLIBC__
+extern const CODE prioritynames[];
+extern const CODE facilitynames[];
+# else
+extern CODE prioritynames[];
+extern CODE facilitynames[];
# endif
+# endif
#endif
/* Decode a symbolic name to a numeric value
*
* Original copyright notice is retained at the end of this file.
*/
-static int decode(char *name, CODE * codetab)
+static int decode(char *name, const CODE *codetab)
{
- CODE *c;
+ const CODE *c;
if (isdigit(*name))
return atoi(name);
}
-int logger_main(int argc, char **argv);
+int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int logger_main(int argc, char **argv)
{
char *str_p, *str_t;
char name[80];
/* Fill out the name string early (may be overwritten later) */
- bb_getpwuid(name, geteuid(), sizeof(name));
+ bb_getpwuid(name, sizeof(name), geteuid());
str_t = name;
/* Parse any options */
- getopt32(argc, argv, "p:st:", &str_p, &str_t);
+ getopt32(argv, "p:st:", &str_p, &str_t);
if (option_mask32 & 0x2) /* -s */
i |= LOG_PERROR;
argc -= optind;
argv += optind;
if (!argc) {
- while (fgets(bb_common_bufsiz1, BUFSIZ, stdin)) {
- if (bb_common_bufsiz1[0]
- && NOT_LONE_CHAR(bb_common_bufsiz1, '\n')
+#define strbuf bb_common_bufsiz1
+ while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
+ if (strbuf[0]
+ && NOT_LONE_CHAR(strbuf, '\n')
) {
/* Neither "" nor "\n" */
- syslog(i, "%s", bb_common_bufsiz1);
+ syslog(i, "%s", strbuf);
}
}
} else {
char *message = NULL;
- int len = 1; /* for NUL */
+ int len = 0;
int pos = 0;
do {
len += strlen(*argv) + 1;
- message = xrealloc(message, len);
+ message = xrealloc(message, len + 1);
sprintf(message + pos, " %s", *argv),
pos = len;
} while (*++argv);