{
struct sockaddr_un sunx;
int fd, pri = LOG_USER|LOG_NOTICE;
+ int fromStdinFlag=FALSE;
int toStdErrFlag=FALSE;
- char *message, buf[1024];
+ int stopLookingAtMeLikeThat=FALSE;
+ char *message, buf[1024], buf1[1024];
time_t now;
size_t addrLength;
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
- while (*(++(*argv))) {
+ if (*((*argv)+1) == '\0') {
+ fromStdinFlag=TRUE;
+ }
+ stopLookingAtMeLikeThat=FALSE;
+ while (*(++(*argv)) && stopLookingAtMeLikeThat==FALSE) {
switch (**argv) {
case 's':
toStdErrFlag = TRUE;
usage(logger_usage);
}
pri = pencode(*(++argv));
- if (--argc == 0) {
- usage(logger_usage);
- }
- ++argv;
+ stopLookingAtMeLikeThat=TRUE;
break;
default:
usage(logger_usage);
}
}
- if (argc>=1)
- if (**argv=='-') {
- /* read from stdin */
+ if (fromStdinFlag==TRUE) {
+ /* read from stdin */
+ int c, i=0;
+ while ((c = getc(stdin)) != EOF && i<sizeof(buf1)) {
+ buf1[i++]=c;
+ }
+ message=buf1;
+ } else {
+ if (argc>=1) {
+ message=*argv;
} else {
- message=*argv;
+ fprintf(stderr, "No message\n");
+ exit( FALSE);
}
- else {
- fprintf(stderr, "No message\n");
- exit( FALSE);
}
memset(&sunx, 0, sizeof(sunx));
if (toStdErrFlag==TRUE)
fprintf(stderr, "%s\n", buf);
- write( fd, buf, sizeof(buf));
+ write( fd, buf, strlen(buf)+1);
close(fd);
exit( TRUE);