1998-10-14 14:22:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2003-11-15 03:11:16 +03:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-09-29 03:12:09 +04:00
|
|
|
*
|
2003-11-15 03:11:16 +03:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-09-29 03:12:09 +04:00
|
|
|
*
|
2001-09-20 04:02:59 +04:00
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
1999-09-29 03:12:09 +04:00
|
|
|
*
|
2003-11-15 03:11:16 +03:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-09-29 03:12:09 +04:00
|
|
|
*
|
2003-11-15 03:11:16 +03:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
1999-09-29 03:12:09 +04:00
|
|
|
*
|
2003-11-15 03:11:16 +03:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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
|
|
|
|
** %s - string
|
2007-12-11 13:09:58 +03:00
|
|
|
** %hs - 16-bit version of above (only available if js_CStringsAreUTF8)
|
2004-12-09 04:32:19 +03:00
|
|
|
** %c - character
|
2007-12-11 13:09:58 +03:00
|
|
|
** %hc - 16-bit version of above (only available if js_CStringsAreUTF8)
|
2004-12-09 04:32:19 +03:00
|
|
|
** %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>
|
|
|
|
|
|
|
|
JS_BEGIN_EXTERN_C
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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
|
|
|
|
|
|
|
JS_END_EXTERN_C
|
|
|
|
|
|
|
|
#endif /* jsprf_h___ */
|