ucx/cx/printf.h

Wed, 31 Dec 2025 16:41:16 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 Dec 2025 16:41:16 +0100
branch
dav-2
changeset 894
e86049631677
parent 889
42cdbf9bbd49
permissions
-rw-r--r--

update ucx to version 4.0

747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
29 * @file printf.h
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
30 * @brief Wrapper for write-functions with a printf-like interface.
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
31 * @author Mike Becker
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
32 * @author Olaf Wintermann
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
33 * @copyright 2-Clause BSD License
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_PRINTF_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_PRINTF_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "common.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "string.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include <stdarg.h>
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
43 /**
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
44 * Attribute for printf-like functions.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
45 * @param fmt_idx index of the format string parameter
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
46 * @param arg_idx index of the first formatting argument
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
47 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
48 #define CX_PRINTF_ARGS(fmt_idx, arg_idx) \
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
49 __attribute__((__format__(printf, fmt_idx, arg_idx)))
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
50
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
51 /**
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
52 * The maximum string length that fits into stack memory.
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
53 */
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
54 CX_EXPORT extern const unsigned cx_printf_sbo_size;
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
55
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
57 * A @c fprintf like function which writes the output to a stream by
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 * using a write_func.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 * @param stream the stream the data is written to
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 * @param wfc the write function
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 * @param fmt format string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 * @param ... additional arguments
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
64 * @return the total number of bytes written or an error code from stdlib printf implementation
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
66 CX_EXTERN CX_NONNULL_ARG(1, 2, 3) CX_PRINTF_ARGS(3, 4) CX_CSTR_ARG(3)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
67 int cx_fprintf(void *stream, cx_write_func wfc, const char *fmt, ...);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
70 * A @c vfprintf like function which writes the output to a stream by
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 * using a write_func.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 * @param stream the stream the data is written to
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 * @param wfc the write function
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 * @param fmt format string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 * @param ap argument list
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
77 * @return the total number of bytes written or an error code from stdlib printf implementation
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 * @see cx_fprintf()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
80 CX_EXTERN CX_NONNULL CX_CSTR_ARG(3)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
81 int cx_vfprintf(void *stream, cx_write_func wfc, const char *fmt, va_list ap);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 /**
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
84 * An @c asprintf like function which allocates space for a string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 * the result is written to.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
87 * @note The resulting string is guaranteed to be zero-terminated,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
88 * unless there was an error, in which case the string's pointer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
89 * will be @c NULL.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 * @param allocator the CxAllocator used for allocating the string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 * @param fmt format string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 * @param ... additional arguments
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 * @return the formatted string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 * @see cx_strfree_a()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
97 CX_EXTERN CX_NONNULL_ARG(1, 2) CX_PRINTF_ARGS(2, 3) CX_CSTR_ARG(2)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
98 cxmutstr cx_asprintf_a(const CxAllocator *allocator, const char *fmt, ...);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 /**
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
101 * An @c asprintf like function which allocates space for a string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 * the result is written to.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
104 * @note The resulting string is guaranteed to be zero-terminated,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
105 * unless there was an error, in which case the string's pointer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
106 * will be @c NULL.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
108 * @param fmt (@c char*) format string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 * @param ... additional arguments
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
110 * @return (@c cxmutstr) the formatted string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 * @see cx_strfree()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 */
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
113 #define cx_asprintf(fmt, ...) cx_asprintf_a(cxDefaultAllocator, fmt, __VA_ARGS__)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
116 * A @c vasprintf like function which allocates space for a string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 * the result is written to.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
119 * @note The resulting string is guaranteed to be zero-terminated,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
120 * unless there was an error, in which case the string's pointer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
121 * will be @c NULL.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 * @param allocator the CxAllocator used for allocating the string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 * @param fmt format string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 * @param ap argument list
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 * @return the formatted string
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 * @see cx_asprintf_a()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
129 CX_EXTERN CX_NONNULL CX_CSTR_ARG(2)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
130 cxmutstr cx_vasprintf_a(const CxAllocator *allocator, const char *fmt, va_list ap);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
133 * A @c vasprintf like function which allocates space for a string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 * the result is written to.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
136 * @note The resulting string is guaranteed to be zero-terminated,
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
137 * unless there was an error, in which case the string's pointer
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
138 * will be @c NULL.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
140 * @param fmt (@c char*) format string
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
141 * @param ap (@c va_list) argument list
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
142 * @return (@c cxmutstr) the formatted string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 * @see cx_asprintf()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 #define cx_vasprintf(fmt, ap) cx_vasprintf_a(cxDefaultAllocator, fmt, ap)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
148 * A @c printf like function which writes the output to a CxBuffer.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
150 * @param buffer (@c CxBuffer*) a pointer to the buffer the data is written to
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
151 * @param fmt (@c char*) the format string
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 * @param ... additional arguments
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
153 * @return (@c int) the total number of bytes written or an error code from stdlib printf implementation
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
154 * @see cx_fprintf()
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
155 * @see cxBufferWrite()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 */
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
157 #define cx_bprintf(buffer, fmt, ...) cx_fprintf((void*)buffer, cxBufferWriteFunc, fmt, __VA_ARGS__)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
159
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
160 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
161 * An @c sprintf like function which reallocates the string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
162 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
163 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
164 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
165 * @note The resulting string, if successful, is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
166 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
167 * @param str (@c char**) a pointer to the string buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
168 * @param len (@c size_t*) a pointer to the length of the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
169 * @param fmt (@c char*) the format string
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
170 * @param ... additional arguments
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
171 * @return (@c int) the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
172 */
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
173 #define cx_sprintf(str, len, fmt, ...) cx_sprintf_a(cxDefaultAllocator, str, len, fmt, __VA_ARGS__)
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
174
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
175 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
176 * An @c sprintf like function which reallocates the string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
177 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
178 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
179 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
180 * @note The resulting string, if successful, is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
181 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
182 * @attention The original buffer MUST have been allocated with the same allocator!
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
183 *
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
184 * @param alloc the allocator to use
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
185 * @param str a pointer to the string buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
186 * @param len a pointer to the length of the buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
187 * @param fmt the format string
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
188 * @param ... additional arguments
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
189 * @return the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
190 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
191 CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) CX_PRINTF_ARGS(4, 5) CX_CSTR_ARG(4)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
192 int cx_sprintf_a(const CxAllocator *alloc, char **str, size_t *len, const char *fmt, ...);
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
193
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
194
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
195 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
196 * An @c sprintf like function which reallocates the string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
197 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
198 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
199 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
200 * @note The resulting string, if successful, is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
201 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
202 * @param str (@c char**) a pointer to the string buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
203 * @param len (@c size_t*) a pointer to the length of the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
204 * @param fmt (@c char*) the format string
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
205 * @param ap (@c va_list) argument list
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
206 * @return (@c int) the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
207 */
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
208 #define cx_vsprintf(str, len, fmt, ap) cx_vsprintf_a(cxDefaultAllocator, str, len, fmt, ap)
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
209
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
210 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
211 * An @c sprintf like function which reallocates the string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
212 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
213 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
214 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
215 * @note The resulting string is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
216 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
217 * @attention The original buffer MUST have been allocated with the same allocator!
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
218 *
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
219 * @param alloc the allocator to use
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
220 * @param str a pointer to the string buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
221 * @param len a pointer to the length of the buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
222 * @param fmt the format string
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
223 * @param ap argument list
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
224 * @return the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
225 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
226 CX_EXTERN CX_NONNULL CX_CSTR_ARG(4) CX_ACCESS_RW(2) CX_ACCESS_RW(3)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
227 int cx_vsprintf_a(const CxAllocator *alloc, char **str, size_t *len, const char *fmt, va_list ap);
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
228
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
229
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
230 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
231 * An @c sprintf like function which allocates a new string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
232 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
233 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
234 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
235 * The location of the resulting string will @em always be stored to @p str. When the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
236 * was sufficiently large, @p buf itself will be stored to the location of @p str.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
237 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
238 * @note The resulting string, if successful, is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
239 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
240 * @remark When a new string needed to be allocated, the contents of @p buf will be
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
241 * poisoned after the call, because this function tries to produce the string in @p buf, first.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
242 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
243 * @param buf (@c char*) a pointer to the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
244 * @param len (@c size_t*) a pointer to the length of the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
245 * @param str (@c char**) a pointer where the location of the result shall be stored
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
246 * @param fmt (@c char*) the format string
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
247 * @param ... additional arguments
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
248 * @return (@c int) the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
249 */
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
250 #define cx_sprintf_s(buf, len, str, fmt, ...) cx_sprintf_sa(cxDefaultAllocator, buf, len, str, fmt, __VA_ARGS__)
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
251
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
252 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
253 * An @c sprintf like function which allocates a new string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
254 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
255 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
256 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
257 * The location of the resulting string will @em always be stored to @p str. When the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
258 * was sufficiently large, @p buf itself will be stored to the location of @p str.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
259 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
260 * @note The resulting string, if successful, is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
261 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
262 * @remark When a new string needed to be allocated, the contents of @p buf will be
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
263 * poisoned after the call, because this function tries to produce the string in @p buf, first.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
264 *
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
265 * @param alloc the allocator to use
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
266 * @param buf a pointer to the buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
267 * @param len a pointer to the length of the buffer
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
268 * @param str a pointer where the location of the result shall be stored
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
269 * @param fmt the format string
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
270 * @param ... additional arguments
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
271 * @return the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
272 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
273 CX_EXTERN CX_NONNULL_ARG(1, 2, 4, 5) CX_PRINTF_ARGS(5, 6) CX_CSTR_ARG(5)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
274 CX_ACCESS_RW(2) CX_ACCESS_RW(3) CX_ACCESS_RW(4)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
275 int cx_sprintf_sa(const CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt, ...);
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
276
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
277 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
278 * An @c sprintf like function which allocates a new string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
279 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
280 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
281 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
282 * The location of the resulting string will @em always be stored to @p str. When the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
283 * was sufficiently large, @p buf itself will be stored to the location of @p str.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
284 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
285 * @note The resulting string is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
286 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
287 * @remark When a new string needed to be allocated, the contents of @p buf will be
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
288 * poisoned after the call, because this function tries to produce the string in @p buf, first.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
289 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
290 * @param buf (@c char*) a pointer to the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
291 * @param len (@c size_t*) a pointer to the length of the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
292 * @param str (@c char**) a pointer where the location of the result shall be stored
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
293 * @param fmt (@c char*) the format string
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
294 * @param ap (@c va_list) argument list
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
295 * @return (@c int) the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
296 */
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
297 #define cx_vsprintf_s(buf, len, str, fmt, ap) cx_vsprintf_sa(cxDefaultAllocator, buf, len, str, fmt, ap)
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
298
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
299 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
300 * An @c sprintf like function which allocates a new string when the buffer is not large enough.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
301 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
302 * The size of the buffer will be updated in @p len when necessary.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
303 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
304 * The location of the resulting string will @em always be stored to @p str. When the buffer
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
305 * was sufficiently large, @p buf itself will be stored to the location of @p str.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
306 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
307 * @note The resulting string is guaranteed to be zero-terminated.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
308 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
309 * @remark When a new string needed to be allocated, the contents of @p buf will be
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
310 * poisoned after the call, because this function tries to produce the string in @p buf, first.
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
311 *
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
312 * @param alloc the allocator to use
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
313 * @param buf a pointer to the buffer
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
314 * @param len a pointer to the length of the buffer
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
315 * @param str a pointer where the location of the result shall be stored
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
316 * @param fmt the format string
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
317 * @param ap argument list
889
42cdbf9bbd49 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 886
diff changeset
318 * @return the length of the produced string or an error code from stdlib printf implementation
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 747
diff changeset
319 */
894
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
320 CX_EXTERN CX_NONNULL CX_CSTR_ARG(5)
e86049631677 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 889
diff changeset
321 int cx_vsprintf_sa(const CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt, va_list ap);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 #endif //UCX_PRINTF_H

mercurial