1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 * The contents of this file are subject to the Mozilla Public
4 * License Version 1.1 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of
6 * the License at http://www.mozilla.org/MPL/
8 * Software distributed under the License is distributed on an "AS
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the License for the specific language governing
11 * rights and limitations under the License.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
15 * The Initial Developer of the Original Code is Netscape
16 * Communications Corporation. Portions created by Netscape are
17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All
22 * Alternatively, the contents of this file may be used under the
23 * terms of the GNU General Public License Version 2 or later (the
24 * "GPL"), in which case the provisions of the GPL are applicable
25 * instead of those above. If you wish to allow use of your
26 * version of this file only under the terms of the GPL and not to
27 * allow others to use your version of this file under the MPL,
28 * indicate your decision by deleting the provisions above and
29 * replace them with the notice and other provisions required by
30 * the GPL. If you do not delete the provisions above, a recipient
31 * may use your version of this file under either the MPL or the
39 ** API for PR printf like routines. Supports the following formats
41 ** %u - unsigned decimal
43 ** %X - unsigned uppercase hex
44 ** %o - unsigned octal
45 ** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
46 ** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
47 ** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
50 ** %p - pointer (deals with machine dependent pointer size)
62 ** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
63 ** of the buffer. Returns the length of the written output, NOT including
64 ** the NUL, or (PRUint32)-1 if an error occurs.
66 NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...);
69 ** sprintf into a PR_MALLOC'd buffer. Return a pointer to the malloc'd
70 ** buffer on success, NULL on failure. Call "PR_smprintf_free" to release
71 ** the memory returned.
73 NSPR_API(char*) PR_smprintf(const char *fmt, ...);
76 ** Free the memory allocated, for the caller, by PR_smprintf
78 NSPR_API(void) PR_smprintf_free(char *mem);
81 ** "append" sprintf into a PR_MALLOC'd buffer. "last" is the last value of
82 ** the PR_MALLOC'd buffer. sprintf will append data to the end of last,
83 ** growing it as necessary using realloc. If last is NULL, PR_sprintf_append
84 ** will allocate the initial string. The return value is the new value of
85 ** last for subsequent calls, or NULL if there is a malloc failure.
87 NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...);
90 ** sprintf into a function. The function "f" is called with a string to
91 ** place into the output. "arg" is an opaque pointer used by the stuff
92 ** function to hold any state needed to do the storage of the output
93 ** data. The return value is a count of the number of characters fed to
94 ** the stuff function, or (PRUint32)-1 if an error occurs.
96 typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);
98 NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...);
101 ** fprintf to a PRFileDesc
103 NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...);
106 ** va_list forms of the above.
108 NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap);
109 NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap);
110 NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap);
111 NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap);
112 NSPR_API(PRUint32) PR_vfprintf(struct PRFileDesc* fd, const char *fmt, va_list ap);
115 ***************************************************************************
116 ** FUNCTION: PR_sscanf
118 ** PR_sscanf() scans the input character string, performs data
119 ** conversions, and stores the converted values in the data objects
120 ** pointed to by its arguments according to the format control
123 ** PR_sscanf() behaves the same way as the sscanf() function in the
124 ** Standard C Library (stdio.h), with the following exceptions:
125 ** - PR_sscanf() handles the NSPR integer and floating point types,
126 ** such as PRInt16, PRInt32, PRInt64, and PRFloat64, whereas
127 ** sscanf() handles the standard C types like short, int, long,
129 ** - PR_sscanf() has no multibyte character support, while sscanf()
133 ** a character string holding the input to scan
135 ** the format control string for the conversions
137 ** variable number of arguments, each of them is a pointer to
138 ** a data object in which the converted value will be stored
141 ** The number of values converted and stored.
143 ** Multibyte characters in 'buf' or 'fmt' are not allowed.
144 ***************************************************************************
147 NSPR_API(PRInt32) PR_sscanf(const char *buf, const char *fmt, ...);
151 #endif /* prprf_h___ */