2013-04-15 23:55:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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
|
|
|
|
|
|
|
#ifndef jsprf_h___
|
|
|
|
#define jsprf_h___
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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
|
|
|
*/
|
|
|
|
#include "jstypes.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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
|
|
|
|
** buffer on success, NULL on failure. Call "JS_smprintf_free" to release
|
|
|
|
** 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,
|
|
|
|
** growing it as necessary using realloc. If last is NULL, JS_sprintf_append
|
|
|
|
** will allocate the initial string. The return value is the new value of
|
|
|
|
** last for subsequent calls, or NULL if there is a malloc failure.
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
** sprintf into a function. The function "f" is called with a string to
|
|
|
|
** place into the output. "arg" is an opaque pointer used by the stuff
|
|
|
|
** function to hold any state needed to do the storage of the output
|
|
|
|
** data. The return value is a count of the number of characters fed to
|
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 stuff function, or (uint32_t)-1 if an error occurs.
|
1998-10-14 14:22:38 +04:00
|
|
|
*/
|
2012-02-11 06:07:35 +04:00
|
|
|
typedef int (*JSStuffFunc)(void *arg, const char *s, uint32_t slen);
|
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_sxprintf(JSStuffFunc f, void *arg, 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);
|
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_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap);
|
1998-10-14 14:22:38 +04:00
|
|
|
|
|
|
|
#endif /* jsprf_h___ */
|