8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / smbsrv / libsmb / common / smb_syslog.c
blobb085627a838b3546c7fdbb96ee705cfb4130f632
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
16 #include <stdio.h>
17 #include <stdarg.h>
18 #include <assert.h>
19 #include <dlfcn.h>
20 #include <errno.h>
21 #include <string.h>
22 #include <syslog.h>
23 #include <smbsrv/libsmb.h>
26 * This is exported NODIRECT so that smbd can provide it's own.
28 void
29 smb_vsyslog(int pri, const char *fmt, va_list ap)
31 vsyslog(pri, fmt, ap);
35 * This is exported NODIRECT so that fksmbd can provide it's own.
37 void
38 smb_syslog(int pri, const char *fmt, ...)
40 va_list ap;
42 va_start(ap, fmt);
43 smb_vsyslog(pri, fmt, ap);
44 va_end(ap);
48 * Helper for smb_vsyslog(). Does %m substitutions.
50 char *
51 smb_syslog_fmt_m(char *buf, int buflen, const char *str, int err)
53 char *bp = buf;
54 const char *sp = str;
55 const char *endp = buf + buflen - 1;
57 while ((*bp = *sp) != '\0' && bp != endp) {
58 if ((*sp++ == '%') && (*sp == 'm')) {
59 sp++;
60 if (strerror_r(err, bp, endp - bp) == 0)
61 bp += strlen(bp);
62 } else {
63 bp++;
66 *bp = '\0';
68 return (buf);