- while ((opt = getopt(argc, argv, "p:st:")) > 0) {
- switch (opt) {
- case 's':
- option |= LOG_PERROR;
- break;
- case 'p':
- pri = pencode(optarg);
- break;
- case 't':
- safe_strncpy(name, optarg, sizeof(name));
- break;
- default:
- bb_show_usage();
- }
- }
-
- openlog(name, option, (pri | LOG_FACMASK));
- if (optind == argc) {
- do {
- /* read from stdin */
- i = 0;
- while ((c = getc(stdin)) != EOF && c != '\n' &&
- i < (sizeof(buf)-1)) {
- buf[i++] = c;
- }
- if (i > 0) {
- buf[i++] = '\0';
- syslog(pri, "%s", buf);
+ getopt32(argc, argv, "p:st:", &opt_p, &opt_t);
+
+ if (option_mask32 & 0x2) /* -s */
+ i |= LOG_PERROR;
+ if (option_mask32 & 0x4) /* -t */
+ safe_strncpy(name, opt_t, sizeof(name));
+ openlog(name, i, 0);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ RELEASE_CONFIG_BUFFER(name);
+ i = LOG_USER | LOG_NOTICE;
+ if (option_mask32 & 0x1) /* -p */
+ i = pencode(opt_p);
+
+ 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')
+ ) {
+ /* Neither "" nor "\n" */
+ syslog(i, "%s", bb_common_bufsiz1);