summaryrefslogtreecommitdiff
path: root/logger.c
diff options
context:
space:
mode:
Diffstat (limited to 'logger.c')
-rw-r--r--logger.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/logger.c b/logger.c
index 0683838..dfbc557 100644
--- a/logger.c
+++ b/logger.c
@@ -118,13 +118,17 @@ extern int logger_main(int argc, char **argv)
{
struct sockaddr_un sunx;
int fd, pri = LOG_USER|LOG_NOTICE;
+ int fromStdinFlag=FALSE;
int toStdErrFlag=FALSE;
- char *message, buf[1024];
+ char *message, buf[1024], buf1[1024];
time_t now;
size_t addrLength;
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
+ if (*((*argv)+1) == '\0') {
+ fromStdinFlag=TRUE;
+ }
while (*(++(*argv))) {
switch (**argv) {
case 's':
@@ -146,15 +150,21 @@ extern int logger_main(int argc, char **argv)
}
}
- if (argc>=1)
- if (**argv=='-') {
- /* read from stdin */
+ if (fromStdinFlag==TRUE) {
+ /* read from stdin */
+ int i=0;
+ char c;
+ 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));