Commit 0d002309 0d0023093b17fdf1ab62d8872307047a8c96d06b by Sergey Poznyakoff

Assorted changes

* include/mailutils/debug.h (mu_debug_format_spec): New function.

* include/mailutils/stream.h (MU_IOCTL_SYSLOGSTREAM)
(MU_IOCTL_FILTER): New ioctls.
(MU_IOCTL_LOGSTREAM_GET_SEVERITY_MASK)
(MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK)
(MU_IOCTL_LOGSTREAM_CLONE)
(MU_IOCTL_SYSLOGSTREAM_SET_LOGGER)
(MU_IOCTL_SYSLOGSTREAM_GET_LOGGER)
(MU_IOCTL_FILTER_GET_DISABLED)
(MU_IOCTL_FILTER_SET_DISABLED): And their opcodes.
* include/mailutils/sys/filter.h (_MU_FILTER_DISABLED)
(_MU_FILTER_EOF): New defines.
(_mu_filter_stream) <eof>: Replace with fltflag (a bitmask).
* include/mailutils/sys/logstream.h (_mu_log_stream) <sevmask>: New
member.
* include/mailutils/sys/syslogstream.h (_mu_syslog_stream) <logger>: New
member.
* include/mailutils/util.h (mu_onexit_run): New proto.
* libmailutils/base/onexit.c (_mu_onexit_run): Extra safety check.
(mu_onexit_run): New function.
(mu_debug_level_str): New static.
(mu_debug_format_spec): New function.
* libmailutils/stream/fltstream.c (filter_read, filter_write): Bypass the
xcoder if _MU_FILTER_DISABLED is set.
Use fltflag instead of the removed eof.
(filter_ctl): Handle MU_IOCTL_FILTER.
* libmailutils/stream/logstream.c (_log_write): The sevmask member
masks out severity prefix output for certain severities.
(_log_ctl): Handle new opcodes (see above).
* libmailutils/stream/syslogstream.c (_syslog_stream_write): Use
<logger>, if supplied, instead of the system syslog(3).
(_syslog_ctl): Handle MU_IOCTL_SYSLOGSTREAM.
(mu_syslog_stream_create): Initialize logger to NULL.
* mu/ldflags.c (lib_descr): Protect entries with the
corresponding #ifdef ENABLE_whatever.
1 parent bc526de1
...@@ -63,6 +63,7 @@ void mu_debug_enable_category (const char *catname, size_t catlen, int level); ...@@ -63,6 +63,7 @@ void mu_debug_enable_category (const char *catname, size_t catlen, int level);
63 void mu_debug_disable_category (const char *catname, size_t catlen); 63 void mu_debug_disable_category (const char *catname, size_t catlen);
64 int mu_debug_category_level (const char *catname, size_t catlen, int *plev); 64 int mu_debug_category_level (const char *catname, size_t catlen, int *plev);
65 void mu_debug_parse_spec (const char *spec); 65 void mu_debug_parse_spec (const char *spec);
66 int mu_debug_format_spec(mu_stream_t str, const char *names, int showunset);
66 67
67 void mu_debug_set_category_level (int catn, int level); 68 void mu_debug_set_category_level (int catn, int level);
68 void mu_debug_clear_all (void); 69 void mu_debug_clear_all (void);
......
...@@ -71,6 +71,8 @@ enum mu_buffer_type ...@@ -71,6 +71,8 @@ enum mu_buffer_type
71 #define MU_IOCTL_LOGSTREAM 7 /* Log stream (see below) */ 71 #define MU_IOCTL_LOGSTREAM 7 /* Log stream (see below) */
72 #define MU_IOCTL_XSCRIPTSTREAM 8 /* Transcript stream (see below) */ 72 #define MU_IOCTL_XSCRIPTSTREAM 8 /* Transcript stream (see below) */
73 #define MU_IOCTL_FD 9 /* File descriptor manipulation */ 73 #define MU_IOCTL_FD 9 /* File descriptor manipulation */
74 #define MU_IOCTL_SYSLOGSTREAM 10 /* Syslog stream (see below) */
75 #define MU_IOCTL_FILTER 11 /* Filter streams (see below) */
74 76
75 /* Opcodes common for various families */ 77 /* Opcodes common for various families */
76 #define MU_IOCTL_OP_GET 0 78 #define MU_IOCTL_OP_GET 0
...@@ -94,8 +96,8 @@ enum mu_buffer_type ...@@ -94,8 +96,8 @@ enum mu_buffer_type
94 #define MU_IOCTL_NULLSTREAM_CLRSIZE 3 96 #define MU_IOCTL_NULLSTREAM_CLRSIZE 3
95 97
96 /* Get or set logging severity. 98 /* Get or set logging severity.
97 Arg: unsigned * 99 Arg: unsigned *
98 */ 100 */
99 #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 101 #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0
100 #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 102 #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1
101 /* Get or set locus. 103 /* Get or set locus.
...@@ -140,6 +142,17 @@ enum mu_buffer_type ...@@ -140,6 +142,17 @@ enum mu_buffer_type
140 */ 142 */
141 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 11 143 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 11
142 144
145 /* Get or set severity output mask.
146 Arg: int *
147 */
148 #define MU_IOCTL_LOGSTREAM_GET_SEVERITY_MASK 12
149 #define MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK 13
150
151 /* Clone the stream.
152 Arg: mu_stream_t*
153 */
154 #define MU_IOCTL_LOGSTREAM_CLONE 14
155
143 /* Opcodes for MU_IOCTL_XSCRIPTSTREAM */ 156 /* Opcodes for MU_IOCTL_XSCRIPTSTREAM */
144 /* Swap transcript levels. 157 /* Swap transcript levels.
145 Arg: int *X 158 Arg: int *X
...@@ -158,6 +171,23 @@ enum mu_buffer_type ...@@ -158,6 +171,23 @@ enum mu_buffer_type
158 Arg: int * 171 Arg: int *
159 */ 172 */
160 #define MU_IOCTL_FD_SET_BORROW 1 173 #define MU_IOCTL_FD_SET_BORROW 1
174
175 /* Opcodes for MU_IOCTL_SYSLOGSTREAM */
176 /* Set logger function.
177 Arg: void (*) (int, const char *, ...)
178 */
179 #define MU_IOCTL_SYSLOGSTREAM_SET_LOGGER 0
180 /* Get logger function.
181 Arg: void (**) (int, const char *, ...)
182 */
183 #define MU_IOCTL_SYSLOGSTREAM_GET_LOGGER 1
184
185 /* Filter streams */
186 /* Get or set disabled state:
187 Arg: int*
188 */
189 #define MU_IOCTL_FILTER_GET_DISABLED 0
190 #define MU_IOCTL_FILTER_SET_DISABLED 1
161 191
162 #define MU_TRANSPORT_INPUT 0 192 #define MU_TRANSPORT_INPUT 0
163 #define MU_TRANSPORT_OUTPUT 1 193 #define MU_TRANSPORT_OUTPUT 1
......
...@@ -36,12 +36,15 @@ struct _mu_filter_buffer ...@@ -36,12 +36,15 @@ struct _mu_filter_buffer
36 size_t pos; 36 size_t pos;
37 }; 37 };
38 38
39 #define _MU_FILTER_DISABLED 0x01
40 #define _MU_FILTER_EOF 0x02
41
39 struct _mu_filter_stream 42 struct _mu_filter_stream
40 { 43 {
41 struct _mu_stream stream; 44 struct _mu_stream stream;
42 mu_stream_t transport; 45 mu_stream_t transport;
43 int mode; 46 int mode;
44 int eof; 47 int fltflag;
45 48
46 struct _mu_filter_buffer inbuf, outbuf; 49 struct _mu_filter_buffer inbuf, outbuf;
47 mu_filter_xcode_t xcode; 50 mu_filter_xcode_t xcode;
......
...@@ -28,6 +28,8 @@ struct _mu_log_stream ...@@ -28,6 +28,8 @@ struct _mu_log_stream
28 unsigned threshold; /* Suppress the output of severities below 28 unsigned threshold; /* Suppress the output of severities below
29 this threshold */ 29 this threshold */
30 int logmode; /* Mode flags */ 30 int logmode; /* Mode flags */
31 int sevmask; /* Mask out the output of severity level for
32 these severities. */
31 struct mu_locus locus; /* Location */ 33 struct mu_locus locus; /* Location */
32 }; 34 };
33 35
......
...@@ -24,6 +24,7 @@ struct _mu_syslog_stream ...@@ -24,6 +24,7 @@ struct _mu_syslog_stream
24 { 24 {
25 struct _mu_stream base; 25 struct _mu_stream base;
26 int prio; 26 int prio;
27 void (*logger) (int, const char *, ...);
27 }; 28 };
28 29
29 #endif 30 #endif
......
...@@ -191,6 +191,8 @@ int mu_fd_wait (int fd, int *pflags, struct timeval *tvp); ...@@ -191,6 +191,8 @@ int mu_fd_wait (int fd, int *pflags, struct timeval *tvp);
191 int mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, 191 int mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab,
192 int *perr); 192 int *perr);
193 193
194 /* Run the onexit list */
195 void mu_onexit_run (void);
194 /* Reset the onexit list. */ 196 /* Reset the onexit list. */
195 void mu_onexit_reset (void); 197 void mu_onexit_reset (void);
196 /* Register the onexit function and associated data */ 198 /* Register the onexit function and associated data */
......
...@@ -42,7 +42,9 @@ _mu_onexit_run (void) ...@@ -42,7 +42,9 @@ _mu_onexit_run (void)
42 { 42 {
43 mu_iterator_t itr; 43 mu_iterator_t itr;
44 int rc, status = 0; 44 int rc, status = 0;
45 45
46 if (!onexit_list)
47 return;
46 rc = mu_list_get_iterator (onexit_list, &itr); 48 rc = mu_list_get_iterator (onexit_list, &itr);
47 if (rc) 49 if (rc)
48 { 50 {
...@@ -97,3 +99,9 @@ mu_onexit_reset (void) ...@@ -97,3 +99,9 @@ mu_onexit_reset (void)
97 { 99 {
98 mu_list_clear (onexit_list); 100 mu_list_clear (onexit_list);
99 } 101 }
102
103 void
104 mu_onexit_run (void)
105 {
106 _mu_onexit_run ();
107 }
......
...@@ -313,6 +313,97 @@ mu_debug_clear_all () ...@@ -313,6 +313,97 @@ mu_debug_clear_all ()
313 cattab[i].isset = 0; 313 cattab[i].isset = 0;
314 } 314 }
315 315
316 #define _LEVEL_ALL MU_DEBUG_LEVEL_UPTO(MU_DEBUG_PROT)
317
318 static char *mu_debug_level_str[] = {
319 "error",
320 "trace0",
321 "trace1",
322 "trace2",
323 "trace3",
324 "trace4",
325 "trace5",
326 "trace6",
327 "trace7",
328 "trace8",
329 "trace9",
330 "prot"
331 };
332
333 static int
334 name_matches (char **names, char *str)
335 {
336 int i;
337
338 for (i = 0; names[i]; i++)
339 if (strcmp (names[i], str) == 0)
340 return 1;
341 return 0;
342 }
343
344 int
345 mu_debug_format_spec(mu_stream_t str, const char *names, int showunset)
346 {
347 int i;
348 size_t cnt = 0;
349 int rc = 0;
350 struct mu_wordsplit ws;
351
352 if (names)
353 {
354 ws.ws_delim = ";";
355 if (mu_wordsplit (names, &ws,
356 MU_WRDSF_DELIM|MU_WRDSF_WS|
357 MU_WRDSF_NOVAR|MU_WRDSF_NOCMD))
358 return errno;
359 }
360
361 for (i = 0; i < catcnt; i++)
362 {
363 if (names && !name_matches (ws.ws_wordv, cattab[i].name))
364 continue;
365 if (cattab[i].isset && cattab[i].level)
366 {
367 if (cnt)
368 {
369 rc = mu_stream_printf(str, ";");
370 if (rc)
371 break;
372 }
373 rc = mu_stream_printf(str, "%s", cattab[i].name);
374 if (rc)
375 break;
376 if (cattab[i].level != _LEVEL_ALL)
377 {
378 int j;
379 int delim = '.';
380
381 for (j = MU_DEBUG_ERROR; j <= MU_DEBUG_PROT; j++)
382 if (cattab[i].level & MU_DEBUG_LEVEL_MASK(j))
383 {
384 rc = mu_stream_printf(str, "%c%s", delim,
385 mu_debug_level_str[j]);
386 if (rc)
387 break;
388 delim = ',';
389 }
390 }
391 cnt++;
392 }
393 else if (showunset)
394 {
395 rc = mu_stream_printf(str, "!%s", cattab[i].name);
396 if (rc)
397 break;
398 cnt++;
399 }
400 }
401 if (names)
402 mu_wordsplit_free (&ws);
403 return rc;
404 }
405
406
316 407
317 void 408 void
318 mu_debug_log (const char *fmt, ...) 409 mu_debug_log (const char *fmt, ...)
......
...@@ -119,6 +119,9 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret) ...@@ -119,6 +119,9 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
119 size_t total = 0; 119 size_t total = 0;
120 int stop = 0; 120 int stop = 0;
121 int again = 0; 121 int again = 0;
122
123 if (fs->fltflag & _MU_FILTER_DISABLED)
124 return mu_stream_read (fs->transport, buf, size, pret);
122 125
123 do 126 do
124 { 127 {
...@@ -129,7 +132,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret) ...@@ -129,7 +132,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
129 enum mu_filter_result res; 132 enum mu_filter_result res;
130 int rc; 133 int rc;
131 134
132 if (fs->eof) 135 if (fs->fltflag & _MU_FILTER_EOF)
133 break; 136 break;
134 137
135 if (MFB_RDBYTES (fs->inbuf) < min_input_level && !again) 138 if (MFB_RDBYTES (fs->inbuf) < min_input_level && !again)
...@@ -178,7 +181,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret) ...@@ -178,7 +181,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
178 again = 0; 181 again = 0;
179 if (cmd == mu_filter_lastbuf || iobuf.eof) 182 if (cmd == mu_filter_lastbuf || iobuf.eof)
180 { 183 {
181 fs->eof = 1; 184 fs->fltflag |= _MU_FILTER_EOF;
182 stop = 1; 185 stop = 1;
183 } 186 }
184 break; 187 break;
...@@ -331,6 +334,11 @@ filter_write_internal (mu_stream_t stream, enum mu_filter_command cmd, ...@@ -331,6 +334,11 @@ filter_write_internal (mu_stream_t stream, enum mu_filter_command cmd,
331 static int 334 static int
332 filter_write (mu_stream_t stream, const char *buf, size_t size, size_t *pret) 335 filter_write (mu_stream_t stream, const char *buf, size_t size, size_t *pret)
333 { 336 {
337 struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
338
339 if (fs->fltflag & _MU_FILTER_DISABLED)
340 return mu_stream_write (fs->transport, buf, size, pret);
341
334 return filter_write_internal (stream, mu_filter_xcode, buf, size, pret); 342 return filter_write_internal (stream, mu_filter_xcode, buf, size, pret);
335 } 343 }
336 344
...@@ -365,6 +373,27 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr) ...@@ -365,6 +373,27 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
365 373
366 switch (code) 374 switch (code)
367 { 375 {
376 case MU_IOCTL_FILTER:
377 switch (opcode)
378 {
379 case MU_IOCTL_FILTER_SET_DISABLED:
380 if (ptr && *(int*)ptr)
381 fs->fltflag |= _MU_FILTER_DISABLED;
382 else
383 fs->fltflag &= ~_MU_FILTER_DISABLED;
384 break;
385
386 case MU_IOCTL_FILTER_GET_DISABLED:
387 if (!ptr)
388 return EINVAL;
389 *(int*)ptr = fs->fltflag & _MU_FILTER_DISABLED;
390 break;
391
392 default:
393 return ENOSYS;
394 }
395 break;
396
368 case MU_IOCTL_TRANSPORT: 397 case MU_IOCTL_TRANSPORT:
369 switch (opcode) 398 switch (opcode)
370 { 399 {
...@@ -414,7 +443,7 @@ static int ...@@ -414,7 +443,7 @@ static int
414 filter_wr_close (mu_stream_t stream) 443 filter_wr_close (mu_stream_t stream)
415 { 444 {
416 struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream; 445 struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
417 if (!mu_stream_eof (stream) && !fs->eof) 446 if (!mu_stream_eof (stream) && !(fs->fltflag & _MU_FILTER_EOF))
418 { 447 {
419 size_t dummy; 448 size_t dummy;
420 int rc = filter_write_internal (stream, mu_filter_lastbuf, NULL, 0, 449 int rc = filter_write_internal (stream, mu_filter_lastbuf, NULL, 0,
...@@ -526,7 +555,7 @@ mu_filter_stream_create (mu_stream_t *pflt, ...@@ -526,7 +555,7 @@ mu_filter_stream_create (mu_stream_t *pflt,
526 fs->xcode = xcode; 555 fs->xcode = xcode;
527 fs->xdata = xdata; 556 fs->xdata = xdata;
528 fs->mode = mode; 557 fs->mode = mode;
529 fs->eof = 0; 558 fs->fltflag = 0;
530 559
531 mu_stream_set_buffer ((mu_stream_t) fs, mu_buffer_full, 560 mu_stream_set_buffer ((mu_stream_t) fs, mu_buffer_full,
532 MU_FILTER_BUF_SIZE); 561 MU_FILTER_BUF_SIZE);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
29 29
30 #include <mailutils/nls.h> 30 #include <mailutils/nls.h>
31 #include <mailutils/stream.h> 31 #include <mailutils/stream.h>
32 #include <mailutils/debug.h>
32 #include <mailutils/sys/logstream.h> 33 #include <mailutils/sys/logstream.h>
33 34
34 char *_mu_severity_str[] = { 35 char *_mu_severity_str[] = {
...@@ -235,7 +236,8 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size, ...@@ -235,7 +236,8 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size,
235 if (fname) 236 if (fname)
236 free (loc.mu_file); 237 free (loc.mu_file);
237 238
238 if (logmode & MU_LOGMODE_SEVERITY) 239 if ((logmode & MU_LOGMODE_SEVERITY) &&
240 !(sp->sevmask & MU_DEBUG_LEVEL_MASK(severity)))
239 { 241 {
240 char *s = gettext (_mu_severity_str[severity]); 242 char *s = gettext (_mu_severity_str[severity]);
241 rc = mu_stream_write (sp->transport, s, strlen (s), NULL); 243 rc = mu_stream_write (sp->transport, s, strlen (s), NULL);
...@@ -418,11 +420,49 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) ...@@ -418,11 +420,49 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
418 else 420 else
419 return mu_severity_from_string ((const char *) arg, &sp->threshold); 421 return mu_severity_from_string ((const char *) arg, &sp->threshold);
420 422
423 case MU_IOCTL_LOGSTREAM_GET_SEVERITY_MASK:
424 if (!arg)
425 return EINVAL;
426 *(int*)arg = sp->sevmask;
427 break;
428
429 case MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK:
430 if (!arg)
431 return EINVAL;
432 sp->sevmask = *(int*)arg;
433 break;
434
435 case MU_IOCTL_LOGSTREAM_CLONE:
436 if (!arg)
437 return EINVAL;
438 else
439 {
440 mu_stream_t str;
441 struct _mu_log_stream *newp;
442 int rc = mu_log_stream_create (&str, sp->transport);
443 if (rc)
444 return rc;
445 newp = (struct _mu_log_stream *) str;
446 newp->severity = sp->severity;
447 newp->threshold = sp->threshold;
448 newp->logmode = sp->logmode;
449 newp->sevmask = sp->sevmask;
450 if (sp->locus.mu_file)
451 newp->locus.mu_file = strdup (sp->locus.mu_file);
452 newp->locus.mu_line = sp->locus.mu_line;
453 newp->locus.mu_col = sp->locus.mu_col;
454 *(mu_stream_t*) arg = str;
455 }
456 break;
457
421 default: 458 default:
422 return EINVAL; 459 return EINVAL;
423 } 460 }
424 break; 461 break;
425 462
463 case MU_IOCTL_FILTER:
464 return mu_stream_ioctl (sp->transport, code, opcode, arg);
465
426 default: 466 default:
427 return ENOSYS; 467 return ENOSYS;
428 } 468 }
......
...@@ -36,7 +36,10 @@ _syslog_stream_write (struct _mu_stream *stream, const char *buf, ...@@ -36,7 +36,10 @@ _syslog_stream_write (struct _mu_stream *stream, const char *buf,
36 size--; 36 size--;
37 if (size == 0) 37 if (size == 0)
38 return 0; 38 return 0;
39 syslog (lsp->prio, "%*.*s", (int) size, (int) size, buf); 39 if (lsp->logger)
40 lsp->logger (lsp->prio, "%*.*s", (int) size, (int) size, buf);
41 else
42 syslog (lsp->prio, "%*.*s", (int) size, (int) size, buf);
40 return 0; 43 return 0;
41 } 44 }
42 45
...@@ -57,35 +60,53 @@ _syslog_ctl (struct _mu_stream *str, int code, int opcode, void *arg) ...@@ -57,35 +60,53 @@ _syslog_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
57 struct _mu_syslog_stream *sp = (struct _mu_syslog_stream *)str; 60 struct _mu_syslog_stream *sp = (struct _mu_syslog_stream *)str;
58 unsigned n; 61 unsigned n;
59 62
60 if (code != MU_IOCTL_LOGSTREAM) 63 if (code == MU_IOCTL_LOGSTREAM)
61 return ENOSYS; 64 switch (opcode)
62 65 {
63 switch (opcode) 66 case MU_IOCTL_LOGSTREAM_GET_SEVERITY:
67 if (!arg)
68 return EINVAL;
69 for (n = 0; n < MU_ARRAY_SIZE (sev2prio); n++)
70 if (sev2prio[n] == sp->prio)
71 {
72 *(int*)arg = n;
73 break;
74 }
75 return MU_ERR_FAILURE;
76
77 case MU_IOCTL_LOGSTREAM_SET_SEVERITY:
78 if (!arg)
79 return EINVAL;
80 n = *(unsigned*)arg;
81 if (n < MU_ARRAY_SIZE (sev2prio))
82 sp->prio = sev2prio[n];
83 else
84 return EINVAL;
85 break;
86
87 default:
88 return ENOSYS;
89 }
90 else if (code == MU_IOCTL_SYSLOGSTREAM)
64 { 91 {
65 case MU_IOCTL_LOGSTREAM_GET_SEVERITY:
66 if (!arg)
67 return EINVAL;
68 for (n = 0; n < MU_ARRAY_SIZE (sev2prio); n++)
69 if (sev2prio[n] == sp->prio)
70 {
71 *(int*)arg = n;
72 break;
73 }
74 return MU_ERR_FAILURE;
75
76 case MU_IOCTL_LOGSTREAM_SET_SEVERITY:
77 if (!arg) 92 if (!arg)
78 return EINVAL; 93 return EINVAL;
79 n = *(unsigned*)arg; 94 switch (opcode)
80 if (n < MU_ARRAY_SIZE (sev2prio)) 95 {
81 sp->prio = sev2prio[n]; 96 case MU_IOCTL_SYSLOGSTREAM_SET_LOGGER:
82 else 97 sp->logger = arg;
83 return EINVAL; 98 break;
84 break; 99
100 case MU_IOCTL_SYSLOGSTREAM_GET_LOGGER:
101 *(void (**) (int, const char *, ...))arg = sp->logger;
102 break;
85 103
86 default: 104 default:
87 return ENOSYS; 105 return ENOSYS;
106 }
88 } 107 }
108 else
109 return ENOSYS;
89 return 0; 110 return 0;
90 } 111 }
91 112
...@@ -106,6 +127,7 @@ mu_syslog_stream_create (mu_stream_t *pstream, int prio) ...@@ -106,6 +127,7 @@ mu_syslog_stream_create (mu_stream_t *pstream, int prio)
106 if (!str) 127 if (!str)
107 return ENOMEM; 128 return ENOMEM;
108 str->prio = prio; 129 str->prio = prio;
130 str->logger = NULL;
109 str->base.write = _syslog_stream_write; 131 str->base.write = _syslog_stream_write;
110 str->base.ctl = _syslog_ctl; 132 str->base.ctl = _syslog_ctl;
111 str->base.setbuf_hook = _syslog_setbuf_hook; 133 str->base.setbuf_hook = _syslog_setbuf_hook;
......
...@@ -50,11 +50,21 @@ struct lib_descr { ...@@ -50,11 +50,21 @@ struct lib_descr {
50 int flags; 50 int flags;
51 } lib_descr[] = { 51 } lib_descr[] = {
52 { "mbox", "mu_mbox", 0 }, 52 { "mbox", "mu_mbox", 0 },
53 #ifdef ENABLE_MH
53 { "mh", "mu_mh", 0 }, 54 { "mh", "mu_mh", 0 },
55 #endif
56 #ifdef ENABLE_MAILDIR
54 { "maildir","mu_maildir", 0 }, 57 { "maildir","mu_maildir", 0 },
58 #endif
59 #ifdef ENABLE_IMAP
55 { "imap", "mu_imap", NEEDAUTH }, 60 { "imap", "mu_imap", NEEDAUTH },
61 #endif
62 #ifdef ENABLE_POP
56 { "pop", "mu_pop", NEEDAUTH }, 63 { "pop", "mu_pop", NEEDAUTH },
64 #endif
65 #ifdef ENABLE_NNTP
57 { "nntp", "mu_nntp", 0 }, 66 { "nntp", "mu_nntp", 0 },
67 #endif
58 { "mailer", "mu_mailer", 0 }, 68 { "mailer", "mu_mailer", 0 },
59 { "sieve", "mu_sieve", NOTALL }, 69 { "sieve", "mu_sieve", NOTALL },
60 { "compat", "mu_compat" }, 70 { "compat", "mu_compat" },
......