1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 ** API for PR printf like routines. Supports the following formats
13 ** %u - unsigned decimal
15 ** %X - unsigned uppercase hex
16 ** %o - unsigned octal
17 ** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
18 ** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
19 ** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
23 ** %p - pointer (deals with machine dependent pointer size)
33 ** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
34 ** of the buffer. Returns the length of the written output, NOT including
35 ** the NUL, or (uint32_t)-1 if an error occurs.
37 extern JS_PUBLIC_API(uint32_t) JS_snprintf(char* out
, uint32_t outlen
, const char* fmt
, ...);
40 ** sprintf into a malloc'd buffer. Return a pointer to the malloc'd
41 ** buffer on success, nullptr on failure. Call "JS_smprintf_free" to release
42 ** the memory returned.
44 extern JS_PUBLIC_API(char*) JS_smprintf(const char* fmt
, ...);
47 ** Free the memory allocated, for the caller, by JS_smprintf
49 extern JS_PUBLIC_API(void) JS_smprintf_free(char* mem
);
52 ** "append" sprintf into a malloc'd buffer. "last" is the last value of
53 ** the malloc'd buffer. sprintf will append data to the end of last,
54 ** growing it as necessary using realloc. If last is nullptr, JS_sprintf_append
55 ** will allocate the initial string. The return value is the new value of
56 ** last for subsequent calls, or nullptr if there is a malloc failure.
58 extern JS_PUBLIC_API(char*) JS_sprintf_append(char* last
, const char* fmt
, ...);
61 ** va_list forms of the above.
63 extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char* out
, uint32_t outlen
, const char* fmt
, va_list ap
);
64 extern JS_PUBLIC_API(char*) JS_vsmprintf(const char* fmt
, va_list ap
);
65 extern JS_PUBLIC_API(char*) JS_vsprintf_append(char* last
, const char* fmt
, va_list ap
);