date: accept 'yyyy-mm-dd HH' and 'yyyy-mm-dd' date formats
[oweals/busybox.git] / sysklogd / logread.c
index 1753ce3247a5967f89cd75c43e59deda308900e7..9939569040d3640e5d46181fa9c05fb3e2d27f1d 100644 (file)
@@ -6,9 +6,15 @@
  *
  * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
+//usage:#define logread_trivial_usage
+//usage:       "[-f]"
+//usage:#define logread_full_usage "\n\n"
+//usage:       "Show messages in syslogd's circular buffer\n"
+//usage:     "\n       -f      Output data as log grows"
+
 #include "libbb.h"
 #include <sys/ipc.h>
 #include <sys/sem.h>
@@ -34,7 +40,7 @@ struct globals {
        struct sembuf SMrup[1]; // {0, -1, IPC_NOWAIT | SEM_UNDO},
        struct sembuf SMrdn[2]; // {1, 0}, {0, +1, SEM_UNDO}
        struct shbuf_ds *shbuf;
-};
+} FIX_ALIASING;
 #define G (*(struct globals*)&bb_common_bufsiz1)
 #define SMrup (G.SMrup)
 #define SMrdn (G.SMrdn)
@@ -43,7 +49,7 @@ struct globals {
        memcpy(SMrup, init_sem, sizeof(init_sem)); \
 } while (0)
 
-static void error_exit(const char *str) ATTRIBUTE_NORETURN;
+static void error_exit(const char *str) NORETURN;
 static void error_exit(const char *str)
 {
        //release all acquired resources
@@ -60,7 +66,7 @@ static void sem_up(int semid)
                error_exit("semop[SMrup]");
 }
 
-static void interrupted(int sig ATTRIBUTE_UNUSED)
+static void interrupted(int sig UNUSED_PARAM)
 {
        signal(SIGINT, SIG_IGN);
        shmdt(shbuf);
@@ -68,7 +74,7 @@ static void interrupted(int sig ATTRIBUTE_UNUSED)
 }
 
 int logread_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int logread_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int logread_main(int argc UNUSED_PARAM, char **argv)
 {
        unsigned cur;
        int log_semid; /* ipc semaphore id */
@@ -135,7 +141,7 @@ int logread_main(int argc ATTRIBUTE_UNUSED, char **argv)
                } else { /* logread -f */
                        if (cur == shbuf_tail) {
                                sem_up(log_semid);
-                               fflush(stdout);
+                               fflush_all();
                                sleep(1); /* TODO: replace me with a sleep_on */
                                continue;
                        }