Fix Centurion name.
[0ad.git] / libraries / source / spidermonkey / include-win32-release / nspr / prprf.h
blob22df9089f7228588577f2f3e422f388a032f14f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef prprf_h___
7 #define prprf_h___
9 /*
10 ** API for PR printf like routines. Supports the following formats
11 ** %d - decimal
12 ** %u - unsigned decimal
13 ** %x - unsigned hex
14 ** %X - unsigned uppercase hex
15 ** %o - unsigned octal
16 ** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
17 ** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
18 ** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
19 ** %s - string
20 ** %c - character
21 ** %p - pointer (deals with machine dependent pointer size)
22 ** %f - float
23 ** %g - float
25 #include "prtypes.h"
26 #include "prio.h"
27 #include <stdio.h>
28 #include <stdarg.h>
30 PR_BEGIN_EXTERN_C
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 (PRUint32)-1 if an error occurs.
37 NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...);
40 ** sprintf into a PR_MALLOC'd buffer. Return a pointer to the malloc'd
41 ** buffer on success, NULL on failure. Call "PR_smprintf_free" to release
42 ** the memory returned.
44 NSPR_API(char*) PR_smprintf(const char *fmt, ...);
47 ** Free the memory allocated, for the caller, by PR_smprintf
49 NSPR_API(void) PR_smprintf_free(char *mem);
52 ** "append" sprintf into a PR_MALLOC'd buffer. "last" is the last value of
53 ** the PR_MALLOC'd buffer. sprintf will append data to the end of last,
54 ** growing it as necessary using realloc. If last is NULL, PR_sprintf_append
55 ** will allocate the initial string. The return value is the new value of
56 ** last for subsequent calls, or NULL if there is a malloc failure.
58 NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...);
61 ** sprintf into a function. The function "f" is called with a string to
62 ** place into the output. "arg" is an opaque pointer used by the stuff
63 ** function to hold any state needed to do the storage of the output
64 ** data. The return value is a count of the number of characters fed to
65 ** the stuff function, or (PRUint32)-1 if an error occurs.
67 typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);
69 NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...);
72 ** fprintf to a PRFileDesc
74 NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...);
77 ** va_list forms of the above.
79 NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap);
80 NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap);
81 NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap);
82 NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap);
83 NSPR_API(PRUint32) PR_vfprintf(struct PRFileDesc* fd, const char *fmt, va_list ap);
86 ***************************************************************************
87 ** FUNCTION: PR_sscanf
88 ** DESCRIPTION:
89 ** PR_sscanf() scans the input character string, performs data
90 ** conversions, and stores the converted values in the data objects
91 ** pointed to by its arguments according to the format control
92 ** string.
94 ** PR_sscanf() behaves the same way as the sscanf() function in the
95 ** Standard C Library (stdio.h), with the following exceptions:
96 ** - PR_sscanf() handles the NSPR integer and floating point types,
97 ** such as PRInt16, PRInt32, PRInt64, and PRFloat64, whereas
98 ** sscanf() handles the standard C types like short, int, long,
99 ** and double.
100 ** - PR_sscanf() has no multibyte character support, while sscanf()
101 ** does.
102 ** INPUTS:
103 ** const char *buf
104 ** a character string holding the input to scan
105 ** const char *fmt
106 ** the format control string for the conversions
107 ** ...
108 ** variable number of arguments, each of them is a pointer to
109 ** a data object in which the converted value will be stored
110 ** OUTPUTS: none
111 ** RETURNS: PRInt32
112 ** The number of values converted and stored.
113 ** RESTRICTIONS:
114 ** Multibyte characters in 'buf' or 'fmt' are not allowed.
115 ***************************************************************************
118 NSPR_API(PRInt32) PR_sscanf(const char *buf, const char *fmt, ...);
120 PR_END_EXTERN_C
122 #endif /* prprf_h___ */