--- l2_env.c 2001/11/04 13:55:06 1.2
+++ l2_env.c 2001/11/07 11:37:18 1.3
@@ -51,6 +51,21 @@
env->flushmask = L2_LEVEL_NONE;
for (i = 0; i < L2_MAX_FORMATTERS; i++)
env->formatters[i].cb = NULL;
+ for (i = 0; i < L2_MAX_HANDLERS; i++)
+ env->handlers[i] = NULL;
+
+ /* pre-configure all handlers we ship */
+ l2_env_handler(env, &l2_handler_null);
+ l2_env_handler(env, &l2_handler_fd);
+ l2_env_handler(env, &l2_handler_file);
+ l2_env_handler(env, &l2_handler_pipe);
+ l2_env_handler(env, &l2_handler_socket);
+ l2_env_handler(env, &l2_handler_syslog);
+ l2_env_handler(env, &l2_handler_smtp);
+ l2_env_handler(env, &l2_handler_noop);
+ l2_env_handler(env, &l2_handler_filter);
+ l2_env_handler(env, &l2_handler_prefix);
+ l2_env_handler(env, &l2_handler_buffer);
/* pass new object to caller */
(*envp) = env;
@@ -108,6 +123,28 @@
return L2_OK;
}
+
+/* attach handler to environment */
+l2_result_t l2_env_handler(l2_env_t *env, l2_handler_t *h)
+{
+ int i;
+
+ /* argument sanity check */
+ if (env == NULL || h == NULL)
+ return L2_ERR_ARG;
+
+ /* find next free handler position in handler array */
+ for (i = 0; i < L2_MAX_HANDLERS && env->handlers[i] != NULL; i++)
+ ;
+ if (i == L2_MAX_HANDLERS)
+ return L2_ERR_MEM;
+
+ /* attach handler to env */
+ env->handlers[i] = h;
+ env->handlers[i] = h;
+
+ return L2_OK;
+}
/* remember additional error information */
l2_result_t l2_env_errorinfo(l2_env_t *env, l2_result_t rv, const char *fmt, ...)
|