xpcom/glue/nsTextFormatter.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * This code was copied from xpcom/ds/nsTextFormatter r1.3
michael@0 8 * Memory model and Frozen linkage changes only.
michael@0 9 * -- Prasad <prasad@medhas.org>
michael@0 10 */
michael@0 11
michael@0 12 #ifndef nsTextFormatter_h___
michael@0 13 #define nsTextFormatter_h___
michael@0 14
michael@0 15 /*
michael@0 16 ** API for PR printf like routines. Supports the following formats
michael@0 17 ** %d - decimal
michael@0 18 ** %u - unsigned decimal
michael@0 19 ** %x - unsigned hex
michael@0 20 ** %X - unsigned uppercase hex
michael@0 21 ** %o - unsigned octal
michael@0 22 ** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
michael@0 23 ** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
michael@0 24 ** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
michael@0 25 ** %s - utf8 string
michael@0 26 ** %S - char16_t string
michael@0 27 ** %c - character
michael@0 28 ** %p - pointer (deals with machine dependent pointer size)
michael@0 29 ** %f - float
michael@0 30 ** %g - float
michael@0 31 */
michael@0 32 #include "prio.h"
michael@0 33 #include <stdio.h>
michael@0 34 #include <stdarg.h>
michael@0 35 #include "nscore.h"
michael@0 36 #include "nsStringGlue.h"
michael@0 37
michael@0 38 #ifdef XPCOM_GLUE
michael@0 39 #error "nsTextFormatter is not available in the standalone glue due to NSPR dependencies."
michael@0 40 #endif
michael@0 41
michael@0 42 class NS_COM_GLUE nsTextFormatter {
michael@0 43
michael@0 44 public:
michael@0 45
michael@0 46 /*
michael@0 47 * sprintf into a fixed size buffer. Guarantees that the buffer is null
michael@0 48 * terminated. Returns the length of the written output, NOT including the
michael@0 49 * null terminator, or (uint32_t)-1 if an error occurs.
michael@0 50 */
michael@0 51 static uint32_t snprintf(char16_t *out, uint32_t outlen, const char16_t *fmt, ...);
michael@0 52
michael@0 53 /*
michael@0 54 * sprintf into a nsMemory::Alloc'd buffer. Return a pointer to
michael@0 55 * buffer on success, nullptr on failure.
michael@0 56 */
michael@0 57 static char16_t* smprintf(const char16_t *fmt, ...);
michael@0 58
michael@0 59 static uint32_t ssprintf(nsAString& out, const char16_t* fmt, ...);
michael@0 60
michael@0 61 /*
michael@0 62 * va_list forms of the above.
michael@0 63 */
michael@0 64 static uint32_t vsnprintf(char16_t *out, uint32_t outlen, const char16_t *fmt, va_list ap);
michael@0 65 static char16_t* vsmprintf(const char16_t *fmt, va_list ap);
michael@0 66 static uint32_t vssprintf(nsAString& out, const char16_t *fmt, va_list ap);
michael@0 67
michael@0 68 /*
michael@0 69 * Free the memory allocated, for the caller, by smprintf.
michael@0 70 * -- Deprecated --
michael@0 71 * Callers can substitute calling smprintf_free with nsMemory::Free
michael@0 72 */
michael@0 73 static void smprintf_free(char16_t *mem);
michael@0 74
michael@0 75 };
michael@0 76
michael@0 77 #endif /* nsTextFormatter_h___ */

mercurial