Index: ossp-pkg/sa/sa_test.c RCS File: /v/ossp/cvs/ossp-pkg/sa/sa_test.c,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/sa/sa_test.c,v' 2>/dev/null --- sa_test.c 2001/10/05 11:40:22 1.3 +++ sa_test.c 2001/10/05 12:56:06 1.4 @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include "sa.h" @@ -62,18 +62,19 @@ now = time(NULL); tm = localtime(&now); strftime(caTime, sizeof(caTime), "%b %e %H:%M:%S", tm); - if (uname(&uts) == 0) { - cpHost = strdup(uts.nodename); - if ((cp = strchr(cpHost, '.')) != NULL) - *cp = '\0'; - } - else - cpHost = strdup("0.0.0.0"); /* FIXME */ + if (uname(&uts) == -1) + die("uname"); + cpHost = strdup(uts.nodename); + if ((cp = strchr(cpHost, '.')) != NULL) + *cp = '\0'; strcpy(caTag, "progname[12]: "); if (strlen(caTag) > 32) caTag[32] = '\0'; - sprintf(caBuf, "<%d>%s %s %s%s", LOG_MAIL|LOG_EMERG, caTime, cpHost, caTag, "test"); - fprintf(stderr, "%s\n", caBuf); + sprintf(caBuf, "<16>%s %s %s[%ld]: %s", caTime, cpHost, + argv[0], (long)getpid(), "test for Internet Datagram socket"); + fprintf(stderr, "Send to syslog: \"%s\"\n", caBuf); + + /* send message to syslogd(8) */ nBuf = strlen(caBuf); if (sa_writeto(sa, caBuf, nBuf, (size_t *)&n, ra) != SA_OK) die("sa_writeto");