Debian Codegraph @

OS/os.c-SunOS5

raw
1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
4
5 /* Copyright (c) The Exim Maintainers 2025 - 2026 */
6 /* Copyright (c) Jeremy Harris 2016 - 2025 */
7 /* Copyright (c) University of Cambridge 2016 */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
9 /* See the file NOTICE for conditions of use and distribution. */
10
11 /* Solaris-specific code. This is concatenated onto the generic
12 src/os.c file. */
13
14 #if defined(MISSING_UNSETENV_3) && !defined(COMPILE_UTILITY)
15 # include "setenv.c"
16 #endif
17
18
19 #if _POSIX_C_SOURCE + 0 < 200809L
20 int
21 vdprintf(int fd, const char * fmt, va_list ap)
22 {
23 gstring * g;
24 rmark reset_point = store_mark();
25
26 g = string_vformat(NULL, SVFMT_EXTEND | SVFMT_TAINT_NOCHK, fmt, ap);
27 (void) write(fd, string_from_gstring(g), gstring_length(g));
28
29 store_reset(reset_point);
30 return 0;
31 }
32
33 int
34 dprintf(int fd, const char * fmt, ...)
35 {
36 int ret;
37 va_list ap;
38 va_start(ap, fmt);
39 ret = vdprintf(fd, fmt, ap);
40 va_end(ap);
41 return ret;
42 }
43
44 # ifdef __SunOS_5_10
45 /* This should properly use size_t, but finding the defn seems too hard.
46 For our purposes, ulong should be enough. */
47
48 unsigned long
49 strnlen(const char * s, unsigned long maxlen)
50 {
51 size_t len = 0;
52 while (len < maxlen && *s++) len++;
53 return len;
54 }
55 # endif
56 #endif
57
58 /* End of os.c-SunOS5 */