Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/sysklogd/logger.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 7  Line 7 
7   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8   */   */
9    
10  #include "busybox.h"  /*
11     * Done in syslogd_and_logger.c:
12  #if !defined CONFIG_SYSLOGD  #include "libbb.h"
   
13  #define SYSLOG_NAMES  #define SYSLOG_NAMES
14  #include <sys/syslog.h>  #define SYSLOG_NAMES_CONST
15    #include <syslog.h>
16  #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[];  
 #  endif  
 #endif  
17    
18  /* Decode a symbolic name to a numeric value  /* Decode a symbolic name to a numeric value
19   * this function is based on code   * this function is based on code
# Line 36  Line 22 
22   *   *
23   * Original copyright notice is retained at the end of this file.   * Original copyright notice is retained at the end of this file.
24   */   */
25  static int decode(char *name, CODE * codetab)  static int decode(char *name, const CODE *codetab)
26  {  {
27   CODE *c;   const CODE *c;
28    
29   if (isdigit(*name))   if (isdigit(*name))
30   return atoi(name);   return atoi(name);
# Line 80  static int pencode(char *s) Line 66  static int pencode(char *s)
66   return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));   return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
67  }  }
68    
69    #define strbuf bb_common_bufsiz1
70    
71    int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
72  int logger_main(int argc, char **argv)  int logger_main(int argc, char **argv)
73  {  {
74   char *str_p, *str_t;   char *str_p, *str_t;
# Line 88  int logger_main(int argc, char **argv) Line 76  int logger_main(int argc, char **argv)
76   char name[80];   char name[80];
77    
78   /* Fill out the name string early (may be overwritten later) */   /* Fill out the name string early (may be overwritten later) */
79   bb_getpwuid(name, geteuid(), sizeof(name));   bb_getpwuid(name, sizeof(name), geteuid());
80   str_t = name;   str_t = name;
81    
82   /* Parse any options */   /* Parse any options */
83   getopt32(argc, argv, "p:st:", &str_p, &str_t);   getopt32(argv, "p:st:", &str_p, &str_t);
84    
85   if (option_mask32 & 0x2) /* -s */   if (option_mask32 & 0x2) /* -s */
86   i |= LOG_PERROR;   i |= LOG_PERROR;
# Line 105  int logger_main(int argc, char **argv) Line 93  int logger_main(int argc, char **argv)
93   argc -= optind;   argc -= optind;
94   argv += optind;   argv += optind;
95   if (!argc) {   if (!argc) {
96   while (fgets(bb_common_bufsiz1, BUFSIZ, stdin)) {   while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
97   if (bb_common_bufsiz1[0]   if (strbuf[0]
98   && NOT_LONE_CHAR(bb_common_bufsiz1, '\n')   && NOT_LONE_CHAR(strbuf, '\n')
99   ) {   ) {
100   /* Neither "" nor "\n" */   /* Neither "" nor "\n" */
101   syslog(i, "%s", bb_common_bufsiz1);   syslog(i, "%s", strbuf);
102   }   }
103   }   }
104   } else {   } else {
105   char *message = NULL;   char *message = NULL;
106   int len = 1; /* for NUL */   int len = 0;
107   int pos = 0;   int pos = 0;
108   do {   do {
109   len += strlen(*argv) + 1;   len += strlen(*argv) + 1;
110   message = xrealloc(message, len);   message = xrealloc(message, len + 1);
111   sprintf(message + pos, " %s", *argv),   sprintf(message + pos, " %s", *argv),
112   pos = len;   pos = len;
113   } while (*++argv);   } while (*++argv);
# Line 130  int logger_main(int argc, char **argv) Line 118  int logger_main(int argc, char **argv)
118   return EXIT_SUCCESS;   return EXIT_SUCCESS;
119  }  }
120    
121    /* Clean up. Needed because we are included from syslogd_and_logger.c */
122    #undef strbuf
123    
124  /*-  /*-
125   * Copyright (c) 1983, 1993   * Copyright (c) 1983, 1993

Legend:
Removed from v.532  
changed lines
  Added in v.816