2019-11-04 00:21:39 +05:30
|
|
|
#include <getopt.h>
|
|
|
|
#include <stdio.h>
|
2019-11-03 20:24:36 +05:30
|
|
|
#include <stdlib.h>
|
|
|
|
#include "syslog.h"
|
|
|
|
|
2019-11-04 00:21:39 +05:30
|
|
|
int main(int argc, char *argv[])
|
2019-11-03 20:24:36 +05:30
|
|
|
{
|
2019-11-04 00:21:39 +05:30
|
|
|
char *ident = NULL;
|
2019-11-03 20:24:36 +05:30
|
|
|
char *msg = getenv("MSG");
|
2019-11-04 00:21:39 +05:30
|
|
|
char c;
|
|
|
|
int severity = LOG_NOTICE;
|
|
|
|
int facility = LOG_CONSOLE;
|
|
|
|
int v1 = 0;
|
2019-11-03 20:24:36 +05:30
|
|
|
|
|
|
|
if (!msg)
|
|
|
|
return 1;
|
|
|
|
|
2019-11-04 00:21:39 +05:30
|
|
|
while ((c = getopt(argc, argv, "i:lp")) != EOF) {
|
|
|
|
switch (c) {
|
|
|
|
case 'i':
|
|
|
|
ident = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
setlogmask(LOG_UPTO(severity));
|
|
|
|
severity = LOG_INFO;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p':
|
|
|
|
v1 = 1;
|
|
|
|
facility = LOG_FTP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ident)
|
|
|
|
openlog(ident, LOG_NOWAIT, facility);
|
|
|
|
|
|
|
|
if (v1)
|
2019-11-05 00:40:36 +05:30
|
|
|
syslogp(severity, "MSGID", NULL, "%s", msg);
|
2019-11-04 00:21:39 +05:30
|
|
|
else
|
2019-11-05 00:40:36 +05:30
|
|
|
syslog(severity, "%s", msg);
|
2019-11-04 00:21:39 +05:30
|
|
|
|
|
|
|
if (ident)
|
|
|
|
closelog();
|
2019-11-03 20:24:36 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|