2013-04-17 00:47:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-10-14 14:22:38 +04:00
|
|
|
|
2013-06-20 04:59:46 +04:00
|
|
|
#ifndef jsprf_h
|
|
|
|
#define jsprf_h
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** API for PR printf like routines. Supports the following formats
|
2004-12-09 04:32:19 +03:00
|
|
|
** %d - decimal
|
|
|
|
** %u - unsigned decimal
|
|
|
|
** %x - unsigned hex
|
|
|
|
** %X - unsigned uppercase hex
|
|
|
|
** %o - unsigned octal
|
|
|
|
** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
|
|
|
|
** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
|
|
|
|
** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
|
2012-10-30 00:55:17 +04:00
|
|
|
** %s - ascii string
|
|
|
|
** %hs - ucs2 string
|
2004-12-09 04:32:19 +03:00
|
|
|
** %c - character
|
|
|
|
** %p - pointer (deals with machine dependent pointer size)
|
|
|
|
** %f - float
|
|
|
|
** %g - float
|
1998-10-14 14:22:38 +04:00
|
|
|
*/
|
2013-07-24 04:34:50 +04:00
|
|
|
|
1998-10-14 14:22:38 +04:00
|
|
|
#include <stdarg.h>
|
2013-07-24 04:34:50 +04:00
|
|
|
|
|
|
|
#include "jstypes.h"
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
|
|
|
|
** of the buffer. Returns the length of the written output, NOT including
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 07:54:10 +04:00
|
|
|
** the NUL, or (uint32_t)-1 if an error occurs.
|
1998-10-14 14:22:38 +04:00
|
|
|
*/
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 07:54:10 +04:00
|
|
|
extern JS_PUBLIC_API(uint32_t) JS_snprintf(char *out, uint32_t outlen, const char *fmt, ...);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** sprintf into a malloc'd buffer. Return a pointer to the malloc'd
|
2013-10-07 20:44:00 +04:00
|
|
|
** buffer on success, nullptr on failure. Call "JS_smprintf_free" to release
|
1998-10-14 14:22:38 +04:00
|
|
|
** the memory returned.
|
|
|
|
*/
|
1999-11-23 04:02:28 +03:00
|
|
|
extern JS_PUBLIC_API(char*) JS_smprintf(const char *fmt, ...);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Free the memory allocated, for the caller, by JS_smprintf
|
|
|
|
*/
|
1999-11-23 04:02:28 +03:00
|
|
|
extern JS_PUBLIC_API(void) JS_smprintf_free(char *mem);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** "append" sprintf into a malloc'd buffer. "last" is the last value of
|
|
|
|
** the malloc'd buffer. sprintf will append data to the end of last,
|
2013-10-07 20:44:00 +04:00
|
|
|
** growing it as necessary using realloc. If last is nullptr, JS_sprintf_append
|
1998-10-14 14:22:38 +04:00
|
|
|
** will allocate the initial string. The return value is the new value of
|
2013-10-07 20:44:00 +04:00
|
|
|
** last for subsequent calls, or nullptr if there is a malloc failure.
|
1998-10-14 14:22:38 +04:00
|
|
|
*/
|
1999-11-23 04:02:28 +03:00
|
|
|
extern JS_PUBLIC_API(char*) JS_sprintf_append(char *last, const char *fmt, ...);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** va_list forms of the above.
|
|
|
|
*/
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 07:54:10 +04:00
|
|
|
extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char *out, uint32_t outlen, const char *fmt, va_list ap);
|
1999-11-23 04:02:28 +03:00
|
|
|
extern JS_PUBLIC_API(char*) JS_vsmprintf(const char *fmt, va_list ap);
|
|
|
|
extern JS_PUBLIC_API(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
2013-06-20 04:59:46 +04:00
|
|
|
#endif /* jsprf_h */
|