dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / smbsrv / libsmb / common / smb_syslog.c
blobc3a403231ee60b85a721544b9657ab390ae8f8c6
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>
25 void
26 smb_vsyslog(int pri, const char *fmt, va_list ap)
28 vsyslog(pri, fmt, ap);
31 void
32 smb_syslog(int pri, const char *fmt, ...)
34 va_list ap;
36 va_start(ap, fmt);
37 smb_vsyslog(pri, fmt, ap);
38 va_end(ap);
42 * Helper for smb_vsyslog(). Does %m substitutions.
44 char *
45 smb_syslog_fmt_m(char *buf, int buflen, const char *str, int err)
47 char *bp = buf;
48 const char *sp = str;
49 const char *endp = buf + buflen - 1;
51 while ((*bp = *sp) != '\0' && bp != endp) {
52 if ((*sp++ == '%') && (*sp == 'm')) {
53 sp++;
54 if (strerror_r(err, bp, endp - bp) == 0)
55 bp += strlen(bp);
56 } else {
57 bp++;
60 *bp = '\0';
62 return (buf);