/src/nspr/pr/src/io/prstdio.c
Line | Count | Source (jump to first uncovered line) |
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/. */ |
5 | | |
6 | | #include "primpl.h" |
7 | | |
8 | | #include <string.h> |
9 | | |
10 | | /* |
11 | | ** fprintf to a PRFileDesc |
12 | | */ |
13 | 0 | PR_IMPLEMENT(PRUint32) PR_fprintf(PRFileDesc* fd, const char* fmt, ...) { |
14 | 0 | va_list ap; |
15 | 0 | PRUint32 rv; |
16 | |
|
17 | 0 | va_start(ap, fmt); |
18 | 0 | rv = PR_vfprintf(fd, fmt, ap); |
19 | 0 | va_end(ap); |
20 | 0 | return rv; |
21 | 0 | } |
22 | | |
23 | | PR_IMPLEMENT(PRUint32) |
24 | 0 | PR_vfprintf(PRFileDesc* fd, const char* fmt, va_list ap) { |
25 | | /* XXX this could be better */ |
26 | 0 | PRUint32 rv, len; |
27 | 0 | char* msg = PR_vsmprintf(fmt, ap); |
28 | 0 | if (NULL == msg) { |
29 | 0 | return -1; |
30 | 0 | } |
31 | 0 | len = strlen(msg); |
32 | 0 | rv = PR_Write(fd, msg, len); |
33 | 0 | PR_DELETE(msg); |
34 | 0 | return rv; |
35 | 0 | } |