summaryrefslogtreecommitdiffstats
path: root/syslog.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-07-06 07:20:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-07-06 07:20:18 -0700
commit8b3d6f7449e73781e4442aed029b55810b04c75e (patch)
tree27d1ce418e9ccbfb9a4b440c6e9bc42652833b36 /syslog.c
parent1ed668849f55baabd50a87375a94ae89f7c5f4b7 (diff)
downloadtxr-8b3d6f7449e73781e4442aed029b55810b04c75e.tar.gz
txr-8b3d6f7449e73781e4442aed029b55810b04c75e.tar.bz2
txr-8b3d6f7449e73781e4442aed029b55810b04c75e.zip
Tightening behavior for unimplemented stream ops.
In many cases, if a stream operation is not applicable to a stream, it is not appropriate to just do nothing and return nil. An error must be thrown. * stream.c (unimpl, unimpl_put_string, unimpl_put_char, unimpl_put_byte, unimpl_get_line, unimpl_get_char, unimpl_get_byte, unimpl_unget_char, unimpl_unget_byte, unimpl_seek, null_put_string, null_put_char, null_put_byte, null_get_line, null_get_char, null_get_byte, null_close, null_flush, null_seek, null_set_prop, null_get_error, null_get_error_str, null_clear_error): New static functions. (fill_stream_ops): New function. (null_ops): Use null_put_string, etc., instead of null pointers. (stdio_clear_error, dir_clear_error, cat_clear_error): Return value now indicating whether an error was cleared. (stream_set_prop, stream_get_prop, real_time_stream_p, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, unget_char, unget_byte, put_string, put_char, put_byte, flush_stream): Do not test whether a function in the ops table is defined; just call it, and return its value. (stream_init): Call fill_stream_ops on all stream operation structures so any null pointers are defaulted to appropriate functions. * stream.h (struct strm_ops): clear_error gets return value. (fill_stream_ops): Declared. * syslog.c (syslog_init): Call fill_stream_ops on syslog_strm_ops.
Diffstat (limited to 'syslog.c')
-rw-r--r--syslog.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/syslog.c b/syslog.c
index d4c5fb8a..cfc24cb8 100644
--- a/syslog.c
+++ b/syslog.c
@@ -45,6 +45,8 @@
val prio_k;
+static struct strm_ops syslog_strm_ops;
+
void syslog_init(void)
{
reg_var(intern(lit("log-pid"), user_package), num_fast(LOG_PID));
@@ -77,6 +79,8 @@ void syslog_init(void)
prio_k = intern(lit("prio"), keyword_package);
reg_var(intern(lit("*stdlog*"), user_package), make_syslog_stream(num_fast(LOG_INFO)));
+
+ fill_stream_ops(&syslog_strm_ops);
}
val openlog_wrap(val wident, val optmask, val facility)