|
@@ -14,6 +14,7 @@
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <unistd.h>
|
|
|
+#include <syslog.h>
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
#include <getopt.h>
|
|
|
#endif
|
|
@@ -27,6 +28,7 @@
|
|
|
|
|
|
#include "lub/list.h"
|
|
|
#include "lub/system.h"
|
|
|
+#include "lub/log.h"
|
|
|
#include "clish/shell.h"
|
|
|
|
|
|
#define QUOTE(t) #t
|
|
@@ -52,6 +54,7 @@ int main(int argc, char **argv)
|
|
|
bool_t utf8 = BOOL_FALSE;
|
|
|
bool_t bit8 = BOOL_FALSE;
|
|
|
bool_t log = BOOL_FALSE;
|
|
|
+ int log_facility = LOG_LOCAL0;
|
|
|
bool_t dryrun = BOOL_FALSE;
|
|
|
bool_t dryrun_config = BOOL_FALSE;
|
|
|
const char *xml_path = getenv("CLISH_PATH");
|
|
@@ -73,7 +76,7 @@ int main(int argc, char **argv)
|
|
|
struct sigaction sigpipe_act;
|
|
|
sigset_t sigpipe_set;
|
|
|
|
|
|
- static const char *shortopts = "hvs:ledx:w:i:bqu8okt:c:f:z:";
|
|
|
+ static const char *shortopts = "hvs:ledx:w:i:bqu8oO:kt:c:f:z:";
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
static const struct option longopts[] = {
|
|
|
{"help", 0, NULL, 'h'},
|
|
@@ -90,6 +93,7 @@ int main(int argc, char **argv)
|
|
|
{"utf8", 0, NULL, 'u'},
|
|
|
{"8bit", 0, NULL, '8'},
|
|
|
{"log", 0, NULL, 'o'},
|
|
|
+ {"facility", 1, NULL, 'O'},
|
|
|
{"check", 0, NULL, 'k'},
|
|
|
{"timeout", 1, NULL, 't'},
|
|
|
{"command", 1, NULL, 'c'},
|
|
@@ -150,6 +154,13 @@ int main(int argc, char **argv)
|
|
|
case 'o':
|
|
|
log = BOOL_TRUE;
|
|
|
break;
|
|
|
+ case 'O':
|
|
|
+ if (lub_log_facility(optarg, &log_facility)) {
|
|
|
+ fprintf(stderr, "Error: Illegal syslog facility %s.\n", optarg);
|
|
|
+ help(-1, argv[0]);
|
|
|
+ goto end;
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 'd':
|
|
|
dryrun = BOOL_TRUE;
|
|
|
break;
|
|
@@ -256,8 +267,10 @@ int main(int argc, char **argv)
|
|
|
#endif
|
|
|
}
|
|
|
/* Set logging */
|
|
|
- if (log)
|
|
|
+ if (log) {
|
|
|
clish_shell__set_log(shell, log);
|
|
|
+ clish_shell__set_facility(shell, log_facility);
|
|
|
+ }
|
|
|
/* Set dry-run */
|
|
|
if (dryrun)
|
|
|
clish_shell__set_dryrun(shell, dryrun);
|
|
@@ -377,7 +390,8 @@ static void help(int status, const char *argv0)
|
|
|
printf("\t-i <vars>, --viewid=<vars>\tSet the startup viewid variables.\n");
|
|
|
printf("\t-u, --utf8\tForce UTF-8 encoding.\n");
|
|
|
printf("\t-8, --8bit\tForce 8-bit encoding.\n");
|
|
|
- printf("\t-o, --log\tEnable command logging to syslog's local0.\n");
|
|
|
+ printf("\t-o, --log\tEnable command logging to syslog's.\n");
|
|
|
+ printf("\t-O, --facility\tSyslog facility.\n");
|
|
|
printf("\t-k, --check\tCheck input files for syntax errors only.\n");
|
|
|
printf("\t-t <timeout>, --timeout=<timeout>\tIdle timeout in seconds.\n");
|
|
|
printf("\t-c <command>, --command=<command>\tExecute specified command(s).\n\t\tMultiple options are possible.\n");
|